Skip to content

Commit

Permalink
raft: add TODO for more safety checks
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Kalinnikov <[email protected]>
  • Loading branch information
pav-kv committed Jan 26, 2024
1 parent f64d156 commit 68a7a9e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,11 @@ func (r *raft) handleAppendEntries(m pb.Message) {
func (r *raft) handleHeartbeat(m pb.Message) {
// It is only safe to advance the commit index if our log is a prefix of the
// leader's log. Otherwise, entries at this index may mismatch.
//
// TODO(pav-kv): move this logic to r.raftLog, which is more appropriate for
// handling safety. The raftLog can use the logSynced flag for other safety
// checks. For example, unstable.truncateAndAppend currently may override a
// suffix of the log unconditionally, but it can only be done if !logSynced.
if r.logSynced {
r.raftLog.commitTo(min(m.Commit, r.raftLog.lastIndex()))
}
Expand Down

0 comments on commit 68a7a9e

Please sign in to comment.