Why consensus needs a log

unlosable >= majority(vote) ∩ majority(log)

A vote picks an author, a log fixes what was written and in what order, and only the overlap of two majorities makes an acknowledged write unlosable.

Election and replication are one protocol, not two. The vote chooses who may append in a term, and a majority is required, so two leaders cannot both win the same term. The log is the object agreed on: an entry counts as committed once a majority holds it, and a candidate must carry a log at least as up to date as any voter's before it can win. Together, the two checks make one history.

Candidates request votes for a term, and a candidate wins only with votes from more than half of N. Two candidates therefore cannot both win the same term. The leader appends each client command to its log and replicates it to followers. Once a majority holds an entry, the entry is committed, and followers apply committed entries in log order. Because every replica applies the same entries in the same order, the state machine sees one sequence of commands. A lagging follower is caught up by the leader, which resends the entries it is missing. Each append costs one round trip to the followers, so the commit point moves only as fast as a majority answers.

The abstraction hides that a leader's acknowledgement is not a commit. Suppose the leader writes an entry to its own log and one follower, then replies success and crashes. Only a minority holds the entry, so it was never committed. A surviving node with a shorter log can legitimately win the next election, the entry disappears from the history, and the client's success was false. Now run the same crash after a majority acknowledged. Any majority that elects the next leader must share at least one node with that acknowledging majority. That node holds the entry and refuses any candidate whose log is shorter, so no leader can win without it. The write survives because the election arithmetic cannot produce a leader without it, not because it was written down.

Put the log under state that must never be lost or reordered: leader identity, lock ownership, cluster membership, and the commit record itself. Keep payloads small, because every write pays one round trip to a majority and passes through the leader. Do not expect throughput from it, and do not use it for bulk data. Do not treat it as a replacement for two-phase commit. Raft makes one log identical on every node, while two-phase commit coordinates writes across different partitions so they succeed or fail together. Before choosing, ask whether a lost or reordered write would corrupt correctness. If the answer is no, use a cheaper store.

orders of magnitude
majority
more than half of N

Any two majorities of one cluster share a node, so two leaders cannot both win the same term.

election timeout
hundreds of milliseconds

How long a follower waits without hearing from a leader before it starts an election.

append round trip
one round trip

The time for a leader to send an entry to followers and hear the acknowledgement back.

commit point
a majority holds the entry

The moment the leader may mark an entry committed and let followers apply it.

field note

The naive design lets one vote pick a leader who then writes wherever it likes. That looks sufficient until a partition splits the voters, because two leaders can each be elected by different groups. Each one accepts writes, and the history forks in two.

The wall shows up at the client. A leader acknowledges a write that it stored only on itself, a later leader that never saw the write takes over, and the client's success was never true. Agreement needs one shared order of writes, not just one winner.

The fix moves agreement onto the log. An entry commits only after a majority holds it, and a new leader needs a log at least as up to date as any voter's, as etcd's documentation describes. The lesson: the election chooses an author, while the log and its commit rule make history single, and that is what an acknowledgement really means.