mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: fix Ready.MustSync logic
The previous logic was erroneously setting Ready.MustSync to true when the hard state had not changed because we were comparing an empty hard state to the previous hard state. In combination with another misfeature in CockroachDB (unnecessary writing of empty batches), this was causing a steady stream of synchronous writes to disk.
This commit is contained in:
@@ -57,6 +57,10 @@ func TestRawNodeProposeAndConfChange(t *testing.T) {
|
||||
s.Append(rd.Entries)
|
||||
rawNode.Advance(rd)
|
||||
|
||||
if d := rawNode.Ready(); d.MustSync || !IsEmptyHardState(d.HardState) || len(d.Entries) > 0 {
|
||||
t.Fatalf("expected empty hard state with must-sync=false: %#v", d)
|
||||
}
|
||||
|
||||
rawNode.Campaign()
|
||||
proposed := false
|
||||
var (
|
||||
@@ -329,7 +333,7 @@ func TestRawNodeRestart(t *testing.T) {
|
||||
HardState: emptyState,
|
||||
// commit up to commit index in st
|
||||
CommittedEntries: entries[:st.Commit],
|
||||
MustSync: true,
|
||||
MustSync: false,
|
||||
}
|
||||
|
||||
storage := NewMemoryStorage()
|
||||
@@ -366,7 +370,7 @@ func TestRawNodeRestartFromSnapshot(t *testing.T) {
|
||||
HardState: emptyState,
|
||||
// commit up to commit index in st
|
||||
CommittedEntries: entries,
|
||||
MustSync: true,
|
||||
MustSync: false,
|
||||
}
|
||||
|
||||
s := NewMemoryStorage()
|
||||
|
||||
Reference in New Issue
Block a user