Appending entries
In Raft the leader receives client commands and appends them to its log as entries tagged with the current term and an index. It then sends AppendEntries messages to followers, who append the same entries in the same positions.
Reaching commitment
An entry is committed once the leader has stored it on a majority of nodes. Committed entries are applied to the state machine in log order. The leader tells followers the commit index in later messages so they apply the same entries.
- Each AppendEntries carries the index and term of the entry just before the new ones.
- A follower rejects the message if that previous entry does not match, exposing a divergence.
- The leader then steps its index backward and retries until the logs align, overwriting conflicting follower entries.
The matching property
This back and forth enforces the Log Matching Property: if two logs share an entry at the same index and term, all earlier entries are identical. That invariant lets a new leader safely overwrite stray uncommitted tails while never erasing committed entries.
Key idea
Raft commits an entry once a majority store it, and consistency checks in AppendEntries force every follower log into agreement.