concept Backend & software
Raft elections, terms and stale leaders
A Raft leader wins a majority of votes in one term. An isolated former leader may still report itself as leader, but a server that knows the newer term rejects its older-term request.
What it means
A Raft candidate becomes leader by winning votes from more than half of the voting members in one term. A term is a numbered election period. Each member can vote for at most one candidate per term, and a voter will not grant its vote to a candidate whose log is less up to date than its own.
A server cut off from the others may still report that it is the leader: it may not have heard about the next term. Its report and a newer election result can both be explained without two candidates having won the same term.
Try it
Simulation: Start with five voting members in term 8. Candidate A can reach three members, including itself; B can reach the other two, including itself. Both logs meet their voters’ requirements, so A gets three votes and B gets two. Three votes are needed. A wins, and a server already in term 8 rejects the old leader’s term-7 request as stale.
Raft elections, terms and stale leaders
Show how terms and voting constraints separate valid leadership from stale claims
One candidate has a majority of distinct eligible voters in this fixed term and partition.
Election and message evidence
- WinnerA
- Election term8
- Message term7
- At this observerstale term: reject
Reachability is not a vote. Both groups are bounded by the same membership; the majority denominator never shrinks to the partition. Term comparison is at the stipulated observer.
Evaluated inputs
- Required scenario evidence
- provided
- Servers reachable by A (incl. A)
- 3 servers
- Servers reachable by B (incl. B)
- 2 servers
- Fixed voting members
- 5 servers
- Old leader message term
- 7 term
- Observed election term
- 8 term
- A log eligible for its voters
- yes
- B log eligible for its voters
- yes
Fixed membership, two disjoint partitions, no joint consensus, each candidate votes for self, other reachable voters all grant/reject based on stipulated eligibility. No election timers, actual log comparison, heartbeats, membership transition or proof that any client read/write is safe. Old term comparison does not imply detection everywhere.
About this model
The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.
Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.
Change only Servers reachable by A (incl. A) from 3 to 2. A and B now get two votes each. The fifth member is unavailable to both, but is still a voting member: the threshold stays at three. Neither candidate wins. The term-7 request is still stale at the term-8 server, even though this time there is no winner.
Use Reset to restore all starting values. The examples describe a local simulation, not observations from a running cluster.
Reachable servers are not necessarily votes
Consider a different change from the starting example: leave A’s group at three, but set A log eligible for its voters to no. A still casts its self-vote. The other two members it can reach decline to vote for it, so A gets one vote, not three. B’s two votes are unchanged. This time the obstacle is not a missing connection; it is the voting restriction.
In Raft, a voter compares the terms of the last log entries, not just the term in which the candidates are campaigning. The log ending in the later term is more up to date. If the last-entry terms match, the voter compares the last-entry indexes: the candidate must be at least as far along. The simulation supplies the outcome of that comparison for each group rather than inspecting individual logs. If either outcome is unknown, it gives no tally; an unknown vote is not a rejected vote.
What the message term tells you
A term comparison answers a narrower question than a vote count. A server in term 8 can reject a term-7 request without knowing who won term 8. Conversely, change the message term from 7 to 8 in the starting example. A still wins three votes to two. The message no longer has an older term, but matching numbers alone do not establish that its sender won those votes.
Set both reachable counts to two while keeping five fixed members. One member lies outside both groups, and neither group can reach the majority threshold of three even if all its reachable voters grant votes. The diagram keeps that fifth member in the denominator. The reachable set does not redefine the electorate.
In practice
When two servers report leadership, compare the term on each report before treating them as conflicting accounts of one election. For the term in question, identify the voting membership and look for distinct votes granted to the same candidate. Reachability tells you who could respond, not who granted a vote. If all you have are two leader labels, the election outcome is still unknown.
The etcd 3.6 failure guide describes a network partition in which the majority side remains available and a leader on the minority side steps down. That is implementation guidance, not a deadline by which every isolated Raft server must recognize a new term. This simulation has fixed membership, two disjoint groups, and no election timers or heartbeats.
Use the votes to establish who won a particular term, and the receiver’s term to judge whether a request is stale there. Neither observation, on its own, tells you that a particular client read or write is safe.
Frequently asked questions
Editorial questions based on the listed sources and explicitly labeled local examples.
Can two candidates both obtain a majority in the same fixed term?
No under the fixed membership and one-vote-per-term premise. Any two majorities share at least one voter, who cannot grant both votes in that term. The example uses disjoint groups; changing the membership requires separate protocol rules.
Does a minority immediately know it lost leadership?
Not necessarily. An isolated former leader may still believe it is leader; that observation is different from winning a new majority election.
What does a larger term establish?
It makes a message carrying an older term stale at a server that has learned the larger term. It does not prove all servers have learned it.
Why does voting consider log freshness?
Raft restricts votes to protect leader completeness. The real comparison uses last-log term and index; the lab supplies that eligibility outcome rather than implementing log repair.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- Ongaro and Ousterhout: In Search of an Understandable Consensus Algorithm
5.2,5.4.1. Votes constrained by term/log freshness; AppendEntries checks preceding index/term; conflicting suffix deletion; direct commit rule requires current-term majority, prior entries follow indirectly.
Checked .
- etcd 3.6: Failure modes
Network partition. The etcd 3.6 guide describes a majority side remaining available and a minority leader stepping down during partition. This implementation example is not a timer guarantee for arbitrary Raft deployments.
Checked .