Skip to content

Commit

Permalink
storage: Call evaluateProposal only once
Browse files Browse the repository at this point in the history
This method was previously called both before and after raft, and the
after-raft logic relied on fields that were set in the
ReplicatedProposalData by the before-raft logic. This caused
inconsistencies when cockroachdb#10327 was deployed without freeze-cluster.

Now, evaluateProposal is called only once, either before or after raft,
and the post-raft logic handles the command in whichever fashion is
appropriate for the version that proposed it.

Fixes cockroachdb#10602
  • Loading branch information
bdarnell committed Nov 16, 2016
1 parent 76eb17b commit 875be84
Show file tree
Hide file tree
Showing 9 changed files with 647 additions and 450 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.ReplicatedProposalData
var cmd storagebase.RaftCommand
if err := cmd.Unmarshal(cmdData); err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/roachpb/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestTransactionString(t *testing.T) {
var txnEmpty roachpb.Transaction
_ = txnEmpty.String() // prevent regression of NPE

cmd := storagebase.ReplicatedProposalData{
cmd := storagebase.RaftCommand{
Cmd: &roachpb.BatchRequest{},
}
cmd.Cmd.Txn = &txn
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func raftEntryFormatter(data []byte) string {
// large snapshot entries.
return fmt.Sprintf("[%x] [%d]", commandID, len(data))
}
var cmd storagebase.ReplicatedProposalData
var cmd storagebase.RaftCommand
if err := proto.Unmarshal(encodedCmd, &cmd); err != nil {
return fmt.Sprintf("[error parsing entry: %s]", err)
}
Expand Down
Loading

0 comments on commit 875be84

Please sign in to comment.