ML
System Design

Raft Consensus and Split-Brain: Why Pre-Vote and Leader Leases Prevent Cluster Disruptions

In distributed consensus, network partitions can isolate a follower that endlessly increments its election term. Upon reconnecting, its inflated term forcefully deposes the healthy cluster leader. How the Pre-Vote protocol and Leader Leases protect Raft state machines from phantom elections and stale reads.

November 30, 202611 min readDistributed SystemsRaftConsensusArchitectureKubernetes

In distributed state machines such as etcd, Consul, CockroachDB, and Apache Kafka (KRaft), the Raft consensus algorithm guarantees that a cluster of nodes agrees on a replicated log even in the face of machine crashes and network partitions. The protocol is celebrated for its understandability compared to classical Paxos, yet production operations reveal subtle edge cases that can disrupt entire clusters.

One of the most insidious failure modes involves an isolated follower that continuously attempts elections during a network glitch. When the partition resolves, this single node can forcefully depose a completely healthy cluster leader, triggering service interruptions and request aborts across the control plane. This vulnerability led to the introduction of the Pre-Vote protocol and Leader Leases.

1. The Classical Raft Leader Election Lifecycle

Raft decomposes consensus into three fundamental subproblems: leader election, log replication, and safety. Each node exists in one of three states: Follower, Candidate, or Leader.

Time is divided into arbitrary terms numbered with consecutive integers. Terms act as logical clocks in Raft:

  • Each term begins with an election in which one or more candidates attempt to gain majority support (N/2 + 1).
  • If a candidate wins the election, it serves as leader for the remainder of the term, sending periodic heartbeats (empty AppendEntries RPCs) to prevent follower election timeouts.
  • If an election splits votes and fails, the term ends with no leader, and nodes start a new term after a randomized timeout.

2. The Disrupted Leader Anomaly (Phantom Elections)

Consider a 3-node Raft cluster consisting of Node A (the active leader), Node B (follower), and Node C (follower) operating smoothly in Term 1.

Suppose an asymmetric network partition isolates Node C from the rest of the cluster, while network connectivity between Node A and Node B remains fully operational:

Network Partition Scenario:
[ Node A (Leader, Term 1) ] <-----> [ Node B (Follower, Term 1) ]
           |
         (X) Network Partition
           |
           v
[ Node C (Isolated Follower) ]

The sequence of events unfolds as follows:

  1. Node A and Node B continue serving client read and write traffic without interruption, easily maintaining a 2-node majority quorum.
  2. Node C stops receiving heartbeats from Leader A. Its election timer expires.
  3. Node C converts to Candidate, increments its term to 2, and broadcasts RequestVote RPCs. Because it is isolated, its messages never reach Node A or Node B.
  4. Node C times out again, increments its term to 3, and repeats the election. It continues this loop, eventually elevating its internal term to 8 or 10.
  5. The network partition heals. Node C reconnects to the local network and broadcasts a RequestVote or heartbeat with Term 10.

Now consider the core Raft safety rule: "If a candidate or leader discovers that its term is out of date, it immediately reverts to follower state."

When Leader A receives Node C's message with Term 10 (while A is still in Term 1), Leader A must immediately abdicate leadership and transition to Follower! Active client transactions stall, in-flight writes fail, and the healthy cluster enters an unnecessary election cycle to establish a new leader.

3. The Pre-Vote Protocol: Speculative Elections

To eliminate phantom disruptions, modern consensus implementations implement the Pre-Vote algorithm (introduced in Diego Ongaro's doctoral dissertation). Pre-Vote introduces an intermediate speculative phase before a node is permitted to increment its actual term.

When an election timer expires on a follower:

Pre-Vote State Machine Flow:
Follower (Timer Expires)
    |
    v
PreCandidate (Speculative Phase)
    |-- Does NOT increment currentTerm
    |-- Sends PreVote RPC (with term = currentTerm + 1)
    |
    +--> If Majority Grants PreVote:
    |       Convert to Candidate -> Increment currentTerm -> Real Election
    |
    +--> If Majority Denies PreVote:
            Revert to Follower -> Sleep for randomized timeout

Crucially, peer nodes evaluate two strict conditions before granting a PreVote:

  • Leader Stickiness: If a node has received a valid heartbeat from the current leader within its minimum election timeout, it rejects the PreVote request. The node knows the leader is alive and well, so there is no reason to entertain an election.
  • Log Up-To-Date Rule: If the candidate's log is less up to date than the voter's log (measured by last log index and term), the PreVote is rejected.

Under Pre-Vote, the isolated Node C sends speculative PreVote requests with Term 2. Because Node A and Node B receive each other's heartbeats, they reject Node C's PreVote. Node C never increments its term counter, protecting the cluster from leadership disruption when it reconnects.

4. Stale Reads and Leader Leases

While Pre-Vote secures leader elections, another critical consensus challenge is ensuring linearizable read consistency without paying prohibitive latency penalties.

In standard Raft, a leader cannot simply serve reads from its local state machine without checking with peers. If an asymmetric partition isolated the leader, the remaining nodes might have already elected a new leader and committed newer state. Reading locally from an old leader leads to stale reads (reading uncommitted or obsolete data).

Distributed databases employ two strategies to solve this:

A. ReadIndex (Quorum Verification)

Before responding to a read request, the leader records its current commit index and broadcasts a zero-payload heartbeat to a majority of followers. Once a majority acknowledges leadership, the leader returns the state at that commit index. While strictly correct, ReadIndex introduces one full network round-trip time (RTT) to every read operation.

B. Leader Leases

To achieve sub-millisecond local reads, consensus engines use Leader Leases. When the leader successfully replicates heartbeats to a majority of nodes, it acquires a time-bounded lease (such as 150 milliseconds):

  • Followers guarantee they will not initiate an election or grant votes to another candidate until the lease duration expires.
  • As long as the leader's local clock remains within the lease window, it knows with mathematical certainty that no other leader can exist.
  • The leader serves read queries directly from local memory at sub-millisecond speeds without network round-trips.

Leader leases require monotonic clock guarantees. If a virtual machine undergoes hypervisor CPU suspension or significant clock drift, lease validity can be breached. Systems like CockroachDB combine software leases with bounded clock offset checks to prevent split-brain anomalies under virtualized environments.

Summary

Standard Raft guarantees correctness under classic failure assumptions, but real-world production networks present asymmetric partitions, clock variations, and transient connection blips. Incorporating Pre-Vote prevents isolated nodes from destabilizing healthy leaders with inflated terms, while Leader Leases allow linearizable reads at memory speed. Together, they transform theoretical consensus into a resilient foundation for mission-critical infrastructure.

SharePostLinkedIn

Reader Discussion

2 replies// weighed in

TopNewestAuthor
Add to the thread
Disagree, agree harder, or share your own experience…
Email instead →markdown okbe kind
  1. Rachel Gold· Staff SREAgrees

    the on-call framing throughout this piece is what makes it land. too many infra articles assume you never get paged. those are written by people who never got paged.

    Dec 03, 2026·3 days later
  2. Omar Khalil· Senior SWEKind words

    this is the third article from this blog I've sent to my team this month. you're cooking. don't switch to crypto.

    Dec 05, 2026·5 days later

Worked on something similar? Email ducminhldm@gmail.com — I read every one. The good ones become future posts.

Comments seeded · live discussion via email