Skip to content

Commit 68a7a9e

Browse files
committed
raft: add TODO for more safety checks
Signed-off-by: Pavel Kalinnikov <[email protected]>
1 parent f64d156 commit 68a7a9e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

raft.go

+5
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,11 @@ func (r *raft) handleAppendEntries(m pb.Message) {
17851785
func (r *raft) handleHeartbeat(m pb.Message) {
17861786
// It is only safe to advance the commit index if our log is a prefix of the
17871787
// leader's log. Otherwise, entries at this index may mismatch.
1788+
//
1789+
// TODO(pav-kv): move this logic to r.raftLog, which is more appropriate for
1790+
// handling safety. The raftLog can use the logSynced flag for other safety
1791+
// checks. For example, unstable.truncateAndAppend currently may override a
1792+
// suffix of the log unconditionally, but it can only be done if !logSynced.
17881793
if r.logSynced {
17891794
r.raftLog.commitTo(min(m.Commit, r.raftLog.lastIndex()))
17901795
}

0 commit comments

Comments
 (0)