From 529d0e2ae5e1f0184017bc418cdf448a12887756 Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Tue, 25 Oct 2016 08:27:43 -0400 Subject: [PATCH] storage: absorb RaftCommand into ReplicatedProposalData Remove the `storagebase.RaftCommand` proto by moving its fields onto `ReplicatedProposalData` while preserving the tag numbers. Use that message instead of `RaftCommand` throughout, including on the wire (since the tag numbers were preserved, this does not require any special handling). This in preparation for a follow-up change which adds an experimental switch to use proposer-evaluated KV (#6166). --- pkg/cli/debug.go | 4 +- pkg/roachpb/string_test.go | 2 +- pkg/storage/raft.go | 2 +- pkg/storage/raft.pb.go | 2 +- pkg/storage/raft.proto | 2 +- pkg/storage/replica.go | 48 +- pkg/storage/replica_raftstorage.go | 4 +- pkg/storage/replica_test.go | 10 +- pkg/storage/storagebase/proposer_kv.pb.go | 541 ++++++++-------------- pkg/storage/storagebase/proposer_kv.proto | 89 ++-- 10 files changed, 290 insertions(+), 414 deletions(-) diff --git a/pkg/cli/debug.go b/pkg/cli/debug.go index 9d47f76f8757..4fe9d26df016 100644 --- a/pkg/cli/debug.go +++ b/pkg/cli/debug.go @@ -424,7 +424,7 @@ func tryRaftLogEntry(kv engine.MVCCKeyValue) (string, error) { if ent.Type == raftpb.EntryNormal { if len(ent.Data) > 0 { _, cmdData := storage.DecodeRaftCommand(ent.Data) - var cmd storagebase.RaftCommand + var cmd storagebase.ReplicatedProposalData if err := cmd.Unmarshal(cmdData); err != nil { return "", err } @@ -441,7 +441,7 @@ func tryRaftLogEntry(kv engine.MVCCKeyValue) (string, error) { if err := ctx.Unmarshal(cc.Context); err != nil { return "", err } - var cmd storagebase.RaftCommand + var cmd storagebase.ReplicatedProposalData if err := cmd.Unmarshal(ctx.Payload); err != nil { return "", err } diff --git a/pkg/roachpb/string_test.go b/pkg/roachpb/string_test.go index c82060a2c706..ccc8e46b08ad 100644 --- a/pkg/roachpb/string_test.go +++ b/pkg/roachpb/string_test.go @@ -62,7 +62,7 @@ func TestTransactionString(t *testing.T) { var txnEmpty roachpb.Transaction _ = txnEmpty.String() // prevent regression of NPE - var cmd storagebase.RaftCommand + var cmd storagebase.ReplicatedProposalData cmd.Cmd.Txn = &txn if actStr, idStr := fmt.Sprintf("%s", &cmd), txn.ID.String(); !strings.Contains(actStr, idStr) { t.Fatalf("expected to find '%s' in '%s'", idStr, actStr) diff --git a/pkg/storage/raft.go b/pkg/storage/raft.go index 0127c3475ec6..0cd1c87ef814 100644 --- a/pkg/storage/raft.go +++ b/pkg/storage/raft.go @@ -184,7 +184,7 @@ func raftEntryFormatter(data []byte) string { // large snapshot entries. return fmt.Sprintf("[%x] [%d]", commandID, len(data)) } - var cmd storagebase.RaftCommand + var cmd storagebase.ReplicatedProposalData if err := proto.Unmarshal(encodedCmd, &cmd); err != nil { return fmt.Sprintf("[error parsing entry: %s]", err) } diff --git a/pkg/storage/raft.pb.go b/pkg/storage/raft.pb.go index 978a1ef00322..937926185877 100644 --- a/pkg/storage/raft.pb.go +++ b/pkg/storage/raft.pb.go @@ -203,7 +203,7 @@ func (*SnapshotResponse) Descriptor() ([]byte, []int) { return fileDescriptorRaf type ConfChangeContext struct { CommandID string `protobuf:"bytes,1,opt,name=command_id,json=commandId" json:"command_id"` // Payload is the application-level command (i.e. an encoded - // storagebase.RaftCommand). + // storagebase.ReplicatedProposalData). Payload []byte `protobuf:"bytes,2,opt,name=payload" json:"payload,omitempty"` // Replica contains full details about the replica being added or removed. Replica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,3,opt,name=replica" json:"replica"` diff --git a/pkg/storage/raft.proto b/pkg/storage/raft.proto index 3bee48107e2f..613ac707c04d 100644 --- a/pkg/storage/raft.proto +++ b/pkg/storage/raft.proto @@ -149,7 +149,7 @@ message ConfChangeContext { (gogoproto.customname) = "CommandID"]; // Payload is the application-level command (i.e. an encoded - // storagebase.RaftCommand). + // storagebase.ReplicatedProposalData). optional bytes payload = 2; // Replica contains full details about the replica being added or removed. diff --git a/pkg/storage/replica.go b/pkg/storage/replica.go index 27f035834181..aa0a9f016b06 100644 --- a/pkg/storage/replica.go +++ b/pkg/storage/replica.go @@ -1718,10 +1718,10 @@ func (r *Replica) evaluateProposal( // since evaluating a proposal is expensive (at least under proposer- // evaluated KV). var pd ProposalData - pd.RaftCommand = &storagebase.RaftCommand{ + pd.ReplicatedProposalData = storagebase.ReplicatedProposalData{ RangeID: r.RangeID, OriginReplica: replica, - Cmd: ba, + Cmd: &ba, } pd.ctx = ctx pd.idKey = idKey @@ -1737,13 +1737,13 @@ func (r *Replica) insertProposalLocked(pd *ProposalData) { if r.mu.lastAssignedLeaseIndex < r.mu.state.LeaseAppliedIndex { r.mu.lastAssignedLeaseIndex = r.mu.state.LeaseAppliedIndex } - if !pd.RaftCommand.Cmd.IsLeaseRequest() { + if !pd.Cmd.IsLeaseRequest() { r.mu.lastAssignedLeaseIndex++ } - pd.RaftCommand.MaxLeaseIndex = r.mu.lastAssignedLeaseIndex + pd.MaxLeaseIndex = r.mu.lastAssignedLeaseIndex if log.V(4) { log.Infof(pd.ctx, "submitting proposal %x: maxLeaseIndex=%d", - pd.idKey, pd.RaftCommand.MaxLeaseIndex) + pd.idKey, pd.MaxLeaseIndex) } if _, ok := r.mu.proposals[pd.idKey]; ok { @@ -1838,26 +1838,26 @@ func (r *Replica) isSoloReplicaLocked() bool { } func defaultSubmitProposalLocked(r *Replica, p *ProposalData) error { - if p.RaftCommand.Cmd.Timestamp == hlc.ZeroTimestamp { + if p.Cmd.Timestamp == hlc.ZeroTimestamp { return errors.Errorf("can't propose Raft command with zero timestamp") } ctx := r.AnnotateCtx(context.TODO()) - data, err := protoutil.Marshal(p.RaftCommand) + data, err := protoutil.Marshal(&p.ReplicatedProposalData) if err != nil { return err } defer r.store.enqueueRaftUpdateCheck(r.RangeID) - if union, ok := p.RaftCommand.Cmd.GetArg(roachpb.EndTransaction); ok { + if union, ok := p.Cmd.GetArg(roachpb.EndTransaction); ok { ict := union.(*roachpb.EndTransactionRequest).InternalCommitTrigger if crt := ict.GetChangeReplicasTrigger(); crt != nil { // EndTransactionRequest with a ChangeReplicasTrigger is special // because raft needs to understand it; it cannot simply be an // opaque command. log.Infof(ctx, "proposing %s %+v for range %d: %+v", - crt.ChangeType, crt.Replica, p.RaftCommand.RangeID, crt.UpdatedReplicas) + crt.ChangeType, crt.Replica, p.RangeID, crt.UpdatedReplicas) confChangeCtx := ConfChangeContext{ CommandID: string(p.idKey), @@ -2116,7 +2116,7 @@ func (r *Replica) handleRaftReadyRaftMuLocked(inSnap IncomingSnapshot) error { case raftpb.EntryNormal: var commandID storagebase.CmdIDKey - var command storagebase.RaftCommand + var command storagebase.ReplicatedProposalData // Process committed entries. etcd raft occasionally adds a nil entry // (our own commands are never empty). This happens in two situations: @@ -2154,7 +2154,7 @@ func (r *Replica) handleRaftReadyRaftMuLocked(inSnap IncomingSnapshot) error { if err := ccCtx.Unmarshal(cc.Context); err != nil { return err } - var command storagebase.RaftCommand + var command storagebase.ReplicatedProposalData if err := command.Unmarshal(ccCtx.Payload); err != nil { return err } @@ -2431,7 +2431,7 @@ type pendingCmdSlice []*ProposalData func (s pendingCmdSlice) Len() int { return len(s) } func (s pendingCmdSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s pendingCmdSlice) Less(i, j int) bool { - return s[i].RaftCommand.MaxLeaseIndex < s[j].RaftCommand.MaxLeaseIndex + return s[i].MaxLeaseIndex < s[j].MaxLeaseIndex } //go:generate stringer -type refreshRaftReason @@ -2465,7 +2465,7 @@ func (r *Replica) refreshProposalsLocked(refreshAtDelta int, reason refreshRaftR numShouldRetry := 0 var reproposals pendingCmdSlice for idKey, p := range r.mu.proposals { - if p.RaftCommand.MaxLeaseIndex > maxMustRetryCommandIndex { + if p.MaxLeaseIndex > maxMustRetryCommandIndex { if p.proposedAtTicks > refreshAtTicks { // The command was proposed too recently, don't bother reproprosing // it yet. Note that if refreshAtDelta is 0, refreshAtTicks will be @@ -2716,7 +2716,10 @@ func (r *Replica) reportSnapshotStatus(to uint64, snapErr error) { // which will apply as a no-op (without accessing raftCmd, via an error), // updating only the applied index. func (r *Replica) processRaftCommand( - ctx context.Context, idKey storagebase.CmdIDKey, index uint64, raftCmd storagebase.RaftCommand, + ctx context.Context, + idKey storagebase.CmdIDKey, + index uint64, + raftCmd storagebase.ReplicatedProposalData, ) (pErr *roachpb.Error) { if index == 0 { log.Fatalf(ctx, "processRaftCommand requires a non-zero index") @@ -2827,10 +2830,10 @@ func (r *Replica) processRaftCommand( } r.mu.Unlock() - if splitMergeUnlock := r.maybeAcquireSplitMergeLock(raftCmd.Cmd); splitMergeUnlock != nil { - defer func() { - splitMergeUnlock(pErr) - }() + // TODO(tschottdorf): not all commands have a BatchRequest (for example, + // empty appends). Be more careful with this in proposer-eval'ed KV. + if raftCmd.Cmd == nil { + raftCmd.Cmd = &roachpb.BatchRequest{} } // applyRaftCommand will return "expected" errors, but may also indicate @@ -2840,10 +2843,17 @@ func (r *Replica) processRaftCommand( log.VEventf(ctx, 1, "applying command with forced error: %s", forcedErr) } else { log.Event(ctx, "applying command") + + if splitMergeUnlock := r.maybeAcquireSplitMergeLock(*raftCmd.Cmd); splitMergeUnlock != nil { + defer func() { + splitMergeUnlock(pErr) + }() + } + } var response proposalResult { - pd := r.applyRaftCommand(ctx, idKey, index, leaseIndex, raftCmd.Cmd, forcedErr) + pd := r.applyRaftCommand(ctx, idKey, index, leaseIndex, *raftCmd.Cmd, forcedErr) pd.Err = r.maybeSetCorrupt(ctx, pd.Err) // TODO(tschottdorf): this field should be zeroed earlier. diff --git a/pkg/storage/replica_raftstorage.go b/pkg/storage/replica_raftstorage.go index 59e781535f84..13efc6bc5981 100644 --- a/pkg/storage/replica_raftstorage.go +++ b/pkg/storage/replica_raftstorage.go @@ -711,8 +711,8 @@ const ( raftCommandNoSplitMask = raftCommandNoSplitBit - 1 ) -// encode a command ID, an encoded storagebase.RaftCommand, and whether the -// command contains a split. +// encode a command ID, an encoded storagebase.ReplicatedProposalData, and +// whether the command contains a split. func encodeRaftCommand(commandID storagebase.CmdIDKey, command []byte) []byte { if len(commandID) != raftCommandIDLen { panic(fmt.Sprintf("invalid command ID length; %d != %d", len(commandID), raftCommandIDLen)) diff --git a/pkg/storage/replica_test.go b/pkg/storage/replica_test.go index ed9a106ca2d8..b45deaea477d 100644 --- a/pkg/storage/replica_test.go +++ b/pkg/storage/replica_test.go @@ -1624,7 +1624,7 @@ func TestLeaseConcurrent(t *testing.T) { var seen int32 tc.rng.mu.Lock() tc.rng.mu.submitProposalFn = func(cmd *ProposalData) error { - ll, ok := cmd.RaftCommand.Cmd.Requests[0]. + ll, ok := cmd.Cmd.Requests[0]. GetInner().(*roachpb.RequestLeaseRequest) if !ok || !active.Load().(bool) { return defaultSubmitProposalLocked(tc.rng, cmd) @@ -5815,7 +5815,7 @@ func TestReplicaIDChangePending(t *testing.T) { commandProposed := make(chan struct{}, 1) rng.mu.Lock() rng.mu.submitProposalFn = func(p *ProposalData) error { - if p.RaftCommand.Cmd.Timestamp.Equal(magicTS) { + if p.Cmd.Timestamp.Equal(magicTS) { commandProposed <- struct{}{} } return nil @@ -5847,7 +5847,7 @@ func TestReplicaRetryRaftProposal(t *testing.T) { tc.rng.mu.submitProposalFn = func(cmd *ProposalData) error { if v := cmd.ctx.Value(magicKey{}); v != nil { if curAttempt := atomic.AddInt32(&c, 1); curAttempt == 1 { - cmd.RaftCommand.MaxLeaseIndex = wrongLeaseIndex + cmd.MaxLeaseIndex = wrongLeaseIndex } } return defaultSubmitProposalLocked(tc.rng, cmd) @@ -5987,7 +5987,7 @@ func TestReplicaBurstPendingCommandsAndRepropose(t *testing.T) { tc.rng.mu.Lock() tc.rng.mu.submitProposalFn = func(cmd *ProposalData) error { if v := cmd.ctx.Value(magicKey{}); v != nil { - seenCmds = append(seenCmds, int(cmd.RaftCommand.MaxLeaseIndex)) + seenCmds = append(seenCmds, int(cmd.MaxLeaseIndex)) } return defaultSubmitProposalLocked(tc.rng, cmd) } @@ -6022,7 +6022,7 @@ func TestReplicaBurstPendingCommandsAndRepropose(t *testing.T) { tc.rng.mu.Lock() for _, p := range tc.rng.mu.proposals { if v := p.ctx.Value(magicKey{}); v != nil { - origIndexes = append(origIndexes, int(p.RaftCommand.MaxLeaseIndex)) + origIndexes = append(origIndexes, int(p.MaxLeaseIndex)) } } tc.rng.mu.Unlock() diff --git a/pkg/storage/storagebase/proposer_kv.pb.go b/pkg/storage/storagebase/proposer_kv.pb.go index d595bd350734..4a84325c68f0 100644 --- a/pkg/storage/storagebase/proposer_kv.pb.go +++ b/pkg/storage/storagebase/proposer_kv.pb.go @@ -10,7 +10,6 @@ cockroach/pkg/storage/storagebase/state.proto It has these top-level messages: - RaftCommand Split Merge ReplicatedProposalData @@ -42,46 +41,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package -// A RaftCommand is a command which can be serialized and sent via -// raft. -type RaftCommand struct { - RangeID github_com_cockroachdb_cockroach_pkg_roachpb.RangeID `protobuf:"varint,1,opt,name=range_id,json=rangeId,casttype=github.com/cockroachdb/cockroach/pkg/roachpb.RangeID" json:"range_id"` - OriginReplica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,2,opt,name=origin_replica,json=originReplica" json:"origin_replica"` - Cmd cockroach_roachpb3.BatchRequest `protobuf:"bytes,3,opt,name=cmd" json:"cmd"` - // When the command is applied, its result is an error if the lease log - // counter has already reached (or exceeded) max_lease_index. - // - // The lease index is a replay protection mechanism. Similar to the Raft - // applied index, it is strictly increasing, but may have gaps. A command - // will only apply successfully if its max_lease_index has not been surpassed - // by the Range's applied lease index (in which case the command may need - // to be retried, that is, regenerated with a higher max_lease_index). - // When the command applies, the new lease index will increase to - // max_lease_index (so a potential later replay will fail). - // - // This mechanism was introduced as a simpler alternative to using the Raft - // applied index, which is fraught with complexity due to the need to predict - // exactly the log position at which a command will apply, even when the Raft - // leader is not colocated with the lease holder (which usually proposes all - // commands). - // - // Pinning the lease-index to the assigned slot (as opposed to allowing gaps - // as we do now) is an interesting venue to explore from the standpoint of - // parallelization: One could hope to enforce command ordering in that way - // (without recourse to a higher-level locking primitive such as the command - // queue). This is a hard problem: First of all, managing the pending - // commands gets more involved; a command must not be removed if others have - // been added after it, and on removal, the assignment counters must be - // updated accordingly. Managing retry of proposals becomes trickier as - // well as that uproots whatever ordering was originally envisioned. - MaxLeaseIndex uint64 `protobuf:"varint,4,opt,name=max_lease_index,json=maxLeaseIndex" json:"max_lease_index"` -} - -func (m *RaftCommand) Reset() { *m = RaftCommand{} } -func (m *RaftCommand) String() string { return proto.CompactTextString(m) } -func (*RaftCommand) ProtoMessage() {} -func (*RaftCommand) Descriptor() ([]byte, []int) { return fileDescriptorProposerKv, []int{0} } - // Split is emitted when a Replica commits a split trigger. It signals that the // Replica has prepared the on-disk state for both the left and right hand // sides of the split, and that the left hand side Replica should be updated as @@ -98,7 +57,7 @@ type Split struct { func (m *Split) Reset() { *m = Split{} } func (m *Split) String() string { return proto.CompactTextString(m) } func (*Split) ProtoMessage() {} -func (*Split) Descriptor() ([]byte, []int) { return fileDescriptorProposerKv, []int{1} } +func (*Split) Descriptor() ([]byte, []int) { return fileDescriptorProposerKv, []int{0} } // Merge is emitted by a Replica which commits a transaction with // a MergeTrigger (i.e. absorbs its right neighbor). @@ -109,7 +68,7 @@ type Merge struct { func (m *Merge) Reset() { *m = Merge{} } func (m *Merge) String() string { return proto.CompactTextString(m) } func (*Merge) ProtoMessage() {} -func (*Merge) Descriptor() ([]byte, []int) { return fileDescriptorProposerKv, []int{2} } +func (*Merge) Descriptor() ([]byte, []int) { return fileDescriptorProposerKv, []int{1} } // ReplicaProposalData is the structured information which together with // a RocksDB WriteBatch constitutes the proposal payload in proposer-evaluated @@ -122,73 +81,59 @@ func (*Merge) Descriptor() ([]byte, []int) { return fileDescriptorProposerKv, [] // followers to reliably produce errors for proposals which apply after a // lease change. type ReplicatedProposalData struct { + RangeID github_com_cockroachdb_cockroach_pkg_roachpb.RangeID `protobuf:"varint,1,opt,name=range_id,json=rangeId,casttype=github.com/cockroachdb/cockroach/pkg/roachpb.RangeID" json:"range_id"` + OriginReplica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,2,opt,name=origin_replica,json=originReplica" json:"origin_replica"` + Cmd *cockroach_roachpb3.BatchRequest `protobuf:"bytes,3,opt,name=cmd" json:"cmd,omitempty"` + // When the command is applied, its result is an error if the lease log + // counter has already reached (or exceeded) max_lease_index. + // + // The lease index is a replay protection mechanism. Similar to the Raft + // applied index, it is strictly increasing, but may have gaps. A command + // will only apply successfully if its max_lease_index has not been surpassed + // by the Range's applied lease index (in which case the command may need + // to be retried, that is, regenerated with a higher max_lease_index). + // When the command applies, the new lease index will increase to + // max_lease_index (so a potential later replay will fail). + // + // This mechanism was introduced as a simpler alternative to using the Raft + // applied index, which is fraught with complexity due to the need to predict + // exactly the log position at which a command will apply, even when the Raft + // leader is not colocated with the lease holder (which usually proposes all + // commands). + // + // Pinning the lease-index to the assigned slot (as opposed to allowing gaps + // as we do now) is an interesting venue to explore from the standpoint of + // parallelization: One could hope to enforce command ordering in that way + // (without recourse to a higher-level locking primitive such as the command + // queue). This is a hard problem: First of all, managing the pending + // commands gets more involved; a command must not be removed if others have + // been added after it, and on removal, the assignment counters must be + // updated accordingly. Managing retry of proposals becomes trickier as + // well as that uproots whatever ordering was originally envisioned. + MaxLeaseIndex uint64 `protobuf:"varint,4,opt,name=max_lease_index,json=maxLeaseIndex" json:"max_lease_index"` // Whether to block concurrent readers while processing the proposal data. - BlockReads bool `protobuf:"varint,1,opt,name=block_reads,json=blockReads" json:"block_reads"` + BlockReads bool `protobuf:"varint,5,opt,name=block_reads,json=blockReads" json:"block_reads"` // Updates to the Replica's ReplicaState. By convention and as outlined on // the comment on the ReplicaState message, this field is sparsely populated // and any field set overwrites the corresponding field in the state, perhaps // which additional side effects (for instance on a descriptor update). - State ReplicaState `protobuf:"bytes,2,opt,name=state" json:"state"` - Split *Split `protobuf:"bytes,3,opt,name=split" json:"split,omitempty"` - Merge *Merge `protobuf:"bytes,4,opt,name=merge" json:"merge,omitempty"` + State ReplicaState `protobuf:"bytes,6,opt,name=state" json:"state"` + Split *Split `protobuf:"bytes,7,opt,name=split" json:"split,omitempty"` + Merge *Merge `protobuf:"bytes,8,opt,name=merge" json:"merge,omitempty"` // TODO(tschottdorf): trim this down; we shouldn't need the whole request. - ComputeChecksum *cockroach_roachpb3.ComputeChecksumRequest `protobuf:"bytes,5,opt,name=compute_checksum,json=computeChecksum" json:"compute_checksum,omitempty"` - // Deprecated once proposer-evaluated-kv is in place: the Raft command which - // executes on all Replicas. - RaftCommand *RaftCommand `protobuf:"bytes,999,opt,name=raft_command,json=raftCommand" json:"raft_command,omitempty"` + ComputeChecksum *cockroach_roachpb3.ComputeChecksumRequest `protobuf:"bytes,9,opt,name=compute_checksum,json=computeChecksum" json:"compute_checksum,omitempty"` } func (m *ReplicatedProposalData) Reset() { *m = ReplicatedProposalData{} } func (m *ReplicatedProposalData) String() string { return proto.CompactTextString(m) } func (*ReplicatedProposalData) ProtoMessage() {} -func (*ReplicatedProposalData) Descriptor() ([]byte, []int) { return fileDescriptorProposerKv, []int{3} } +func (*ReplicatedProposalData) Descriptor() ([]byte, []int) { return fileDescriptorProposerKv, []int{2} } func init() { - proto.RegisterType((*RaftCommand)(nil), "cockroach.storage.storagebase.RaftCommand") proto.RegisterType((*Split)(nil), "cockroach.storage.storagebase.Split") proto.RegisterType((*Merge)(nil), "cockroach.storage.storagebase.Merge") proto.RegisterType((*ReplicatedProposalData)(nil), "cockroach.storage.storagebase.ReplicatedProposalData") } -func (m *RaftCommand) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *RaftCommand) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - data[i] = 0x8 - i++ - i = encodeVarintProposerKv(data, i, uint64(m.RangeID)) - data[i] = 0x12 - i++ - i = encodeVarintProposerKv(data, i, uint64(m.OriginReplica.Size())) - n1, err := m.OriginReplica.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n1 - data[i] = 0x1a - i++ - i = encodeVarintProposerKv(data, i, uint64(m.Cmd.Size())) - n2, err := m.Cmd.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n2 - data[i] = 0x20 - i++ - i = encodeVarintProposerKv(data, i, uint64(m.MaxLeaseIndex)) - return i, nil -} - func (m *Split) Marshal() (data []byte, err error) { size := m.Size() data = make([]byte, size) @@ -207,19 +152,19 @@ func (m *Split) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintProposerKv(data, i, uint64(m.SplitTrigger.Size())) - n3, err := m.SplitTrigger.MarshalTo(data[i:]) + n1, err := m.SplitTrigger.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n3 + i += n1 data[i] = 0x12 i++ i = encodeVarintProposerKv(data, i, uint64(m.RHSDelta.Size())) - n4, err := m.RHSDelta.MarshalTo(data[i:]) + n2, err := m.RHSDelta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n4 + i += n2 return i, nil } @@ -241,11 +186,11 @@ func (m *Merge) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintProposerKv(data, i, uint64(m.MergeTrigger.Size())) - n5, err := m.MergeTrigger.MarshalTo(data[i:]) + n3, err := m.MergeTrigger.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n5 + i += n3 return i, nil } @@ -266,13 +211,37 @@ func (m *ReplicatedProposalData) MarshalTo(data []byte) (int, error) { _ = l data[i] = 0x8 i++ + i = encodeVarintProposerKv(data, i, uint64(m.RangeID)) + data[i] = 0x12 + i++ + i = encodeVarintProposerKv(data, i, uint64(m.OriginReplica.Size())) + n4, err := m.OriginReplica.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n4 + if m.Cmd != nil { + data[i] = 0x1a + i++ + i = encodeVarintProposerKv(data, i, uint64(m.Cmd.Size())) + n5, err := m.Cmd.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n5 + } + data[i] = 0x20 + i++ + i = encodeVarintProposerKv(data, i, uint64(m.MaxLeaseIndex)) + data[i] = 0x28 + i++ if m.BlockReads { data[i] = 1 } else { data[i] = 0 } i++ - data[i] = 0x12 + data[i] = 0x32 i++ i = encodeVarintProposerKv(data, i, uint64(m.State.Size())) n6, err := m.State.MarshalTo(data[i:]) @@ -281,7 +250,7 @@ func (m *ReplicatedProposalData) MarshalTo(data []byte) (int, error) { } i += n6 if m.Split != nil { - data[i] = 0x1a + data[i] = 0x3a i++ i = encodeVarintProposerKv(data, i, uint64(m.Split.Size())) n7, err := m.Split.MarshalTo(data[i:]) @@ -291,7 +260,7 @@ func (m *ReplicatedProposalData) MarshalTo(data []byte) (int, error) { i += n7 } if m.Merge != nil { - data[i] = 0x22 + data[i] = 0x42 i++ i = encodeVarintProposerKv(data, i, uint64(m.Merge.Size())) n8, err := m.Merge.MarshalTo(data[i:]) @@ -301,7 +270,7 @@ func (m *ReplicatedProposalData) MarshalTo(data []byte) (int, error) { i += n8 } if m.ComputeChecksum != nil { - data[i] = 0x2a + data[i] = 0x4a i++ i = encodeVarintProposerKv(data, i, uint64(m.ComputeChecksum.Size())) n9, err := m.ComputeChecksum.MarshalTo(data[i:]) @@ -310,18 +279,6 @@ func (m *ReplicatedProposalData) MarshalTo(data []byte) (int, error) { } i += n9 } - if m.RaftCommand != nil { - data[i] = 0xba - i++ - data[i] = 0x3e - i++ - i = encodeVarintProposerKv(data, i, uint64(m.RaftCommand.Size())) - n10, err := m.RaftCommand.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n10 - } return i, nil } @@ -352,18 +309,6 @@ func encodeVarintProposerKv(data []byte, offset int, v uint64) int { data[offset] = uint8(v) return offset + 1 } -func (m *RaftCommand) Size() (n int) { - var l int - _ = l - n += 1 + sovProposerKv(uint64(m.RangeID)) - l = m.OriginReplica.Size() - n += 1 + l + sovProposerKv(uint64(l)) - l = m.Cmd.Size() - n += 1 + l + sovProposerKv(uint64(l)) - n += 1 + sovProposerKv(uint64(m.MaxLeaseIndex)) - return n -} - func (m *Split) Size() (n int) { var l int _ = l @@ -385,6 +330,14 @@ func (m *Merge) Size() (n int) { func (m *ReplicatedProposalData) Size() (n int) { var l int _ = l + n += 1 + sovProposerKv(uint64(m.RangeID)) + l = m.OriginReplica.Size() + n += 1 + l + sovProposerKv(uint64(l)) + if m.Cmd != nil { + l = m.Cmd.Size() + n += 1 + l + sovProposerKv(uint64(l)) + } + n += 1 + sovProposerKv(uint64(m.MaxLeaseIndex)) n += 2 l = m.State.Size() n += 1 + l + sovProposerKv(uint64(l)) @@ -400,10 +353,6 @@ func (m *ReplicatedProposalData) Size() (n int) { l = m.ComputeChecksum.Size() n += 1 + l + sovProposerKv(uint64(l)) } - if m.RaftCommand != nil { - l = m.RaftCommand.Size() - n += 2 + l + sovProposerKv(uint64(l)) - } return n } @@ -420,7 +369,7 @@ func sovProposerKv(x uint64) (n int) { func sozProposerKv(x uint64) (n int) { return sovProposerKv(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *RaftCommand) Unmarshal(data []byte) error { +func (m *Split) Unmarshal(data []byte) error { l := len(data) iNdEx := 0 for iNdEx < l { @@ -443,34 +392,15 @@ func (m *RaftCommand) Unmarshal(data []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RaftCommand: wiretype end group for non-group") + return fmt.Errorf("proto: Split: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RaftCommand: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Split: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RangeID", wireType) - } - m.RangeID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposerKv - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - m.RangeID |= (github_com_cockroachdb_cockroach_pkg_roachpb.RangeID(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OriginReplica", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SplitTrigger", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -494,13 +424,13 @@ func (m *RaftCommand) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.OriginReplica.Unmarshal(data[iNdEx:postIndex]); err != nil { + if err := m.SplitTrigger.Unmarshal(data[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cmd", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RHSDelta", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -524,29 +454,10 @@ func (m *RaftCommand) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Cmd.Unmarshal(data[iNdEx:postIndex]); err != nil { + if err := m.RHSDelta.Unmarshal(data[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxLeaseIndex", wireType) - } - m.MaxLeaseIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposerKv - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - m.MaxLeaseIndex |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipProposerKv(data[iNdEx:]) @@ -568,7 +479,7 @@ func (m *RaftCommand) Unmarshal(data []byte) error { } return nil } -func (m *Split) Unmarshal(data []byte) error { +func (m *Merge) Unmarshal(data []byte) error { l := len(data) iNdEx := 0 for iNdEx < l { @@ -591,45 +502,15 @@ func (m *Split) Unmarshal(data []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Split: wiretype end group for non-group") + return fmt.Errorf("proto: Merge: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Split: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Merge: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SplitTrigger", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposerKv - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProposerKv - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SplitTrigger.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RHSDelta", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MergeTrigger", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -653,7 +534,7 @@ func (m *Split) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.RHSDelta.Unmarshal(data[iNdEx:postIndex]); err != nil { + if err := m.MergeTrigger.Unmarshal(data[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -678,7 +559,7 @@ func (m *Split) Unmarshal(data []byte) error { } return nil } -func (m *Merge) Unmarshal(data []byte) error { +func (m *ReplicatedProposalData) Unmarshal(data []byte) error { l := len(data) iNdEx := 0 for iNdEx < l { @@ -701,15 +582,34 @@ func (m *Merge) Unmarshal(data []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Merge: wiretype end group for non-group") + return fmt.Errorf("proto: ReplicatedProposalData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Merge: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ReplicatedProposalData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RangeID", wireType) + } + m.RangeID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposerKv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + m.RangeID |= (github_com_cockroachdb_cockroach_pkg_roachpb.RangeID(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MergeTrigger", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OriginReplica", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -733,61 +633,63 @@ func (m *Merge) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.MergeTrigger.Unmarshal(data[iNdEx:postIndex]); err != nil { + if err := m.OriginReplica.Unmarshal(data[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProposerKv(data[iNdEx:]) - if err != nil { - return err + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cmd", wireType) } - if skippy < 0 { + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposerKv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { return ErrInvalidLengthProposerKv } - if (iNdEx + skippy) > l { + postIndex := iNdEx + msglen + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ReplicatedProposalData) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposerKv + if m.Cmd == nil { + m.Cmd = &cockroach_roachpb3.BatchRequest{} } - if iNdEx >= l { - return io.ErrUnexpectedEOF + if err := m.Cmd.Unmarshal(data[iNdEx:postIndex]); err != nil { + return err } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxLeaseIndex", wireType) } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ReplicatedProposalData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ReplicatedProposalData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + m.MaxLeaseIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposerKv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + m.MaxLeaseIndex |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field BlockReads", wireType) } @@ -807,7 +709,7 @@ func (m *ReplicatedProposalData) Unmarshal(data []byte) error { } } m.BlockReads = bool(v != 0) - case 2: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) } @@ -837,7 +739,7 @@ func (m *ReplicatedProposalData) Unmarshal(data []byte) error { return err } iNdEx = postIndex - case 3: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Split", wireType) } @@ -870,7 +772,7 @@ func (m *ReplicatedProposalData) Unmarshal(data []byte) error { return err } iNdEx = postIndex - case 4: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Merge", wireType) } @@ -903,7 +805,7 @@ func (m *ReplicatedProposalData) Unmarshal(data []byte) error { return err } iNdEx = postIndex - case 5: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ComputeChecksum", wireType) } @@ -936,39 +838,6 @@ func (m *ReplicatedProposalData) Unmarshal(data []byte) error { return err } iNdEx = postIndex - case 999: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RaftCommand", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposerKv - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProposerKv - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RaftCommand == nil { - m.RaftCommand = &RaftCommand{} - } - if err := m.RaftCommand.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipProposerKv(data[iNdEx:]) @@ -1100,44 +969,42 @@ func init() { } var fileDescriptorProposerKv = []byte{ - // 620 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x53, 0x41, 0x6b, 0xd4, 0x40, - 0x14, 0x6e, 0xba, 0x5d, 0x76, 0x9d, 0x55, 0x5b, 0x06, 0x91, 0xa5, 0xe0, 0x66, 0x59, 0x5a, 0xa8, - 0x5a, 0x13, 0x51, 0x41, 0xf0, 0x98, 0x2c, 0xd4, 0x42, 0x2b, 0x3a, 0x2d, 0x1e, 0xf4, 0x10, 0x26, - 0x93, 0x69, 0x12, 0x36, 0xc9, 0xc4, 0x99, 0xd9, 0xd2, 0x9f, 0xe1, 0xaf, 0x10, 0xc4, 0x3f, 0xd2, - 0x63, 0x8f, 0x9e, 0x16, 0x5d, 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f, 0x4f, 0x2c, 0x05, 0x00, 0x00, + // 584 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0xad, 0xbf, 0x24, 0x5f, 0xdc, 0x89, 0xa0, 0x95, 0x85, 0x90, 0x55, 0x09, 0x3b, 0x8a, 0x5a, + 0x29, 0x88, 0x62, 0xf3, 0xb7, 0x62, 0xe9, 0x44, 0x2a, 0x91, 0x5a, 0x09, 0x26, 0x15, 0x0b, 0x58, + 0x58, 0xe3, 0xf1, 0xc8, 0xb6, 0x62, 0x67, 0xcc, 0xcc, 0xa4, 0xca, 0x63, 0xf0, 0x1a, 0xbc, 0x49, + 0x96, 0x5d, 0xb2, 0x8a, 0x20, 0xec, 0x79, 0x00, 0x56, 0x68, 0xc6, 0xe3, 0x92, 0xaa, 0x2e, 0x74, + 0xe5, 0xd1, 0xbd, 0xe7, 0x9c, 0x39, 0xf7, 0xcc, 0x35, 0x78, 0x89, 0x29, 0x9e, 0x31, 0x8a, 0x70, + 0xea, 0x97, 0xb3, 0xc4, 0xe7, 0x82, 0x32, 0x94, 0x90, 0xfa, 0x1b, 0x21, 0x4e, 0xfc, 0x92, 0xd1, + 0x92, 0x72, 0xc2, 0xc2, 0xd9, 0x85, 0x57, 0x32, 0x2a, 0xa8, 0xf5, 0xe8, 0x8a, 0xe4, 0x69, 0xa0, + 0xb7, 0x45, 0x38, 0x70, 0xaf, 0x6b, 0xaa, 0x53, 0x19, 0xf9, 0xa8, 0xcc, 0x2a, 0xfe, 0x41, 0xbf, + 0x19, 0x10, 0x23, 0x81, 0x34, 0xe2, 0xb0, 0x19, 0x51, 0x10, 0x81, 0xb6, 0x50, 0xcf, 0x9a, 0xcd, + 0x93, 0x79, 0x92, 0xcd, 0xeb, 0x8f, 0x64, 0x5d, 0x60, 0xac, 0x19, 0x4f, 0xff, 0x3d, 0x2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d, 0x7c, 0xbd, 0x1e, 0x1c, + 0xad, 0xbe, 0x3b, 0x3b, 0xab, 0x8d, 0x63, 0x5c, 0x6e, 0x1c, 0xe3, 0xeb, 0xc6, 0x31, 0xbe, 0x6d, + 0x1c, 0xe3, 0xf3, 0x0f, 0x67, 0xe7, 0x43, 0x6f, 0xcb, 0xc9, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xbc, 0xfe, 0x8b, 0x90, 0xc6, 0x04, 0x00, 0x00, } diff --git a/pkg/storage/storagebase/proposer_kv.proto b/pkg/storage/storagebase/proposer_kv.proto index 313633d5aa63..b139502b89af 100644 --- a/pkg/storage/storagebase/proposer_kv.proto +++ b/pkg/storage/storagebase/proposer_kv.proto @@ -24,14 +24,45 @@ import "cockroach/pkg/storage/storagebase/state.proto"; import "gogoproto/gogo.proto"; -// A RaftCommand is a command which can be serialized and sent via -// raft. -message RaftCommand { +// Split is emitted when a Replica commits a split trigger. It signals that the +// Replica has prepared the on-disk state for both the left and right hand +// sides of the split, and that the left hand side Replica should be updated as +// well as the right hand side created. +message Split { + optional roachpb.SplitTrigger trigger = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; + // RHSDelta holds the statistics for what was written to what is now the + // right-hand side of the split during the batch which executed it. + // The on-disk state of the right-hand side is already correct, but the + // Store must learn about this delta to update its counters appropriately. + optional storage.engine.enginepb.MVCCStats rhs_delta = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "RHSDelta"]; +} + +// Merge is emitted by a Replica which commits a transaction with +// a MergeTrigger (i.e. absorbs its right neighbor). +message Merge { + optional roachpb.MergeTrigger trigger = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; +} + +// ReplicaProposalData is the structured information which together with +// a RocksDB WriteBatch constitutes the proposal payload in proposer-evaluated +// KV. For the majority of proposals, we expect ReplicatedProposalData to be +// trivial; only changes to the metadata state (splits, merges, rebalances, +// leases, log truncation, ...) of the Replica or certain special commands must +// sideline information here based on which all Replicas must take action. +// +// TODO(tschottdorf): We may need to add a lease identifier to allow the +// followers to reliably produce errors for proposals which apply after a +// lease change. +message ReplicatedProposalData { + // ====================================== + // Begin of what was formerly RaftCommand + // ====================================== + optional int64 range_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "RangeID", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.RangeID"]; optional roachpb.ReplicaDescriptor origin_replica = 2 [(gogoproto.nullable) = false]; - optional roachpb.BatchRequest cmd = 3 [(gogoproto.nullable) = false]; + optional roachpb.BatchRequest cmd = 3; // When the command is applied, its result is an error if the lease log // counter has already reached (or exceeded) max_lease_index. // @@ -59,54 +90,22 @@ message RaftCommand { // updated accordingly. Managing retry of proposals becomes trickier as // well as that uproots whatever ordering was originally envisioned. optional uint64 max_lease_index = 4 [(gogoproto.nullable) = false]; -} + // ====================================== + // End of what was formerly RaftCommand + // ====================================== - -// Split is emitted when a Replica commits a split trigger. It signals that the -// Replica has prepared the on-disk state for both the left and right hand -// sides of the split, and that the left hand side Replica should be updated as -// well as the right hand side created. -message Split { - optional roachpb.SplitTrigger trigger = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; - // RHSDelta holds the statistics for what was written to what is now the - // right-hand side of the split during the batch which executed it. - // The on-disk state of the right-hand side is already correct, but the - // Store must learn about this delta to update its counters appropriately. - optional storage.engine.enginepb.MVCCStats rhs_delta = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "RHSDelta"]; -} - -// Merge is emitted by a Replica which commits a transaction with -// a MergeTrigger (i.e. absorbs its right neighbor). -message Merge { - optional roachpb.MergeTrigger trigger = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; -} - -// ReplicaProposalData is the structured information which together with -// a RocksDB WriteBatch constitutes the proposal payload in proposer-evaluated -// KV. For the majority of proposals, we expect ReplicatedProposalData to be -// trivial; only changes to the metadata state (splits, merges, rebalances, -// leases, log truncation, ...) of the Replica or certain special commands must -// sideline information here based on which all Replicas must take action. -// -// TODO(tschottdorf): We may need to add a lease identifier to allow the -// followers to reliably produce errors for proposals which apply after a -// lease change. -message ReplicatedProposalData { // Whether to block concurrent readers while processing the proposal data. - optional bool block_reads = 1 [(gogoproto.nullable) = false]; + optional bool block_reads = 5 [(gogoproto.nullable) = false]; // Updates to the Replica's ReplicaState. By convention and as outlined on // the comment on the ReplicaState message, this field is sparsely populated // and any field set overwrites the corresponding field in the state, perhaps // which additional side effects (for instance on a descriptor update). - optional storage.storagebase.ReplicaState state = 2 [(gogoproto.nullable) = false]; - optional Split split = 3; - optional Merge merge = 4; + optional storage.storagebase.ReplicaState state = 6 [(gogoproto.nullable) = false]; + optional Split split = 7; + optional Merge merge = 8; // TODO(tschottdorf): trim this down; we shouldn't need the whole request. - optional roachpb.ComputeChecksumRequest compute_checksum = 5; - // TODO(tschottdorf): add the WriteBatch. + optional roachpb.ComputeChecksumRequest compute_checksum = 9; - // Deprecated once proposer-evaluated-kv is in place: the Raft command which - // executes on all Replicas. - optional RaftCommand raft_command = 999; + // TODO(tschottdorf): add the WriteBatch here. }