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:
Peter Mattis
2018-09-18 23:17:51 -04:00
parent ab544f2dde
commit 66ee394527
2 changed files with 7 additions and 3 deletions

View File

@@ -575,7 +575,7 @@ func newReady(r *raft, prevSoftSt *SoftState, prevHardSt pb.HardState) Ready {
if len(r.readStates) != 0 {
rd.ReadStates = r.readStates
}
rd.MustSync = MustSync(rd.HardState, prevHardSt, len(rd.Entries))
rd.MustSync = MustSync(r.hardState(), prevHardSt, len(rd.Entries))
return rd
}