Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raft: advance commit index safely #139

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Jan 27, 2024

  1. raft: advance commit index safely

    This change makes the commit index advancement in handleHeartbeat safe.
    Previously, a follower would attempt to update the commit index to
    whichever was sent in the MsgHeartbeat message. Out-of-bound indices
    would crash the node.
    
    It is always safe to advance a commit index if the follower's log is "in
    sync" with the leader, i.e. when its log is guaranteed to be a prefix of
    the leader's log. This is always true if the term of last entry in the
    log matches the leader team, otherwise this guarantee is established
    when the first MsgApp append message from the leader succeeds.
    
    At the moment, the leader will never send a commit index that exceeds
    the follower's log size. However, this may change in future. This change
    is a defence-in-depth.
    
    The newly added raftLog.leaderTerm field will be used for other safety
    checks in the future, for example to establish that overriding a suffix
    of entries in raftLog is safe.
    
    Signed-off-by: Pavel Kalinnikov <[email protected]>
    pav-kv committed Jan 27, 2024
    Configuration menu
    Copy the full SHA
    87ac09e View commit details
    Browse the repository at this point in the history

Commits on Jan 29, 2024

  1. raft: pass the leader term to append/commit methods

    This change improves safety of the append operations on raftLog. This
    helped fixing some tests which made incorrect assumptions about the log.
    
    Signed-off-by: Pavel Kalinnikov <[email protected]>
    pav-kv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    4e08f52 View commit details
    Browse the repository at this point in the history