Safety: Leader Completeness Property
What you'll learn: How Raft guarantees that once a log entry is committed, every future leader will have that entry in their log.
The Core Guarantee
The Leader Completeness Property is Raft's fundamental safety rule: if a log entry is committed in a given term, that entry will be present in the logs of all leaders for all higher-numbered terms.
In simpler terms: once the system agrees on something (commits it), no future leader can "forget" it or overwrite it with something else.
Why This Matters
Remember that in Raft, only the leader can tell followers what's committed. But leaders can crash and new ones get elected. Without this property, a new leader might lack previously committed entries, causing the system to lose acknowledged writes—a catastrophic safety violation.
How Raft Enforces It
During leader election (RequestVote RPC), candidates only win if they have logs that are "at least as up-to-date" as a majority of servers. This check happens through:
- Term comparison first: Higher term number = more up-to-date
- Log length as tiebreaker: Longer log = more up-to-date
Since a majority must have acknowledged a committed entry, and a new leader needs votes from a majority, at least one voter must have that committed entry. The "up-to-date" check ensures the new leader's log contains it.
Analogy
Think of committed entries as historical facts published in a majority of newspapers. Any candidate for president must have read at least one of those newspapers to qualify—ensuring they know all published history.
Key Takeaway: The Leader Completeness Property prevents data loss by ensuring election rules guarantee every new leader has all previously committed log entries, maintaining safety across leader transitions.