When Quorum Fails: Surviving Split-Brain in Distributed Consensus Systems (Raft/Paxos)
Distributed consensus algorithms like Raft and Paxos offer mathematical guarantees on paper, but in the physical reality of cloud data centers, un-fenced minority leaders, asymmetric network partitions, and hypervisor pauses reliably induce split-brain state divergence.
TL;DR
- Problem: Logical quorum intersection ($Q = \lfloor N/2 \rfloor + 1$) does not stop a partitioned old leader from serving stale reads or writing to shared storage if its lease timer stalls or STONITH lags.
- Answer: Layer three defenses: Raft Pre-Vote (
--pre-vote=truein etcd) to block isolated term inflation, monotonic self-fencing (CLOCK_MONOTONIC_RAW) for leader leases, and monotonically increasing fencing tokens validated at the storage boundary.- Watch out:
CLOCK_MONOTONIC_RAWprotects against NTP slew, not hypervisor VM freezes; storage-side epoch verification is mandatory to close the zombie-leader write window.
Situation
Distributed, consensus-driven engines form the control plane and storage backbone of modern cloud infrastructure. Systems such as etcd (coordinating Kubernetes cluster state), CockroachDB and TiKV (distributed SQL and key-value storage), Patroni with etcd or Consul (PostgreSQL failover), and Apache Kafka KRaft rely on quorum consensus derived from Raft or Multi-Paxos.
These algorithms guarantee safety across crash-recovery failures via the Quorum Intersection Principle. In a cluster of $N = 2F + 1$ voting members, a write commits only after acknowledgments from a majority quorum $Q = \lfloor N/2 \rfloor + 1$. Because any two majorities overlap by at least one node ($|Q_1 \cap Q_2| \ge 1$), any newly elected leader is guaranteed to have observed all previously committed log entries.
Platform teams routinely deploy 3-node or 5-node clusters across three cloud Availability Zones (AZs) assuming that odd-numbered quorum alone prevents split-brain corruption. In quorum arithmetic, a 3-node cluster ($Q = 2$, $F = 1$) tolerates one node loss; a 4-node cluster ($Q = 3$, $F = 1$) still tolerates only one node loss while increasing replication fan-out; and a 5-node cluster ($Q = 3$, $F = 2$) is required before the cluster can survive two simultaneous node failures (for example, one planned maintenance reboot plus one unplanned AZ outage).
The Problem
Idealized consensus proofs assume a crash-recovery model where nodes either run or stop cleanly. Physical cloud infrastructure introduces four constraints that break naive quorum deployments:
- Asymmetric Network Partitions: Real network faults are frequently partial: a switch bug or misconfigured security group lets Node A send to Node B and Node B reach Node C, while Node C cannot reach Node A. In standard Raft without Pre-Vote, follower C misses leader A’s heartbeats, increments
currentTerm($T \to T+1$), and broadcastsRequestVote. Even though C cannot win a majority without A, anyRequestVoteorAppendEntriespacket from C that reaches B carries term $T+1$. Per Raft Section 5.1, any node receiving an RPC with a higher term immediately updates its term to $T+1$ and reverts to Follower—meaning a single asymmetrically isolated follower forces the healthy leader to step down repeatedly and stalls cluster progress. - The Zombie Leader Window: When AZ1 partitions from AZ2 and AZ3, the majority in AZ2 and AZ3 elects a new leader at Term $T+1$. However, the old leader in AZ1 may still be running and reachable by clients in AZ1. If the old leader serves reads using a local lease or writes to shared storage without an epoch check, it creates divergent state during the window before external health checks or STONITH terminate it.
- Hypervisor Pauses and Clock Drift: Consensus systems use time-bounded Leader Leases so leaders can serve linearizable reads locally without a quorum round-trip per query. However, if the leader VM experiences a hypervisor live-migration pause, snapshot freeze, or long GC stop-the-world pause, the guest OS stops advancing while physical time moves forward. When the VM resumes, it may still believe its lease is valid even after the majority has elected a new leader. Note that Linux
CLOCK_MONOTONIC_RAWprevents NTP step/slew distortions, but it does not advance while an entire VM is frozen by the hypervisor. - Remote Witness Latency Floor: Placing a lightweight witness or tie-breaker node in a distant region to save compute costs penalizes every consensus commit. Because a 3-node cluster requires 2 of 3 votes, if one local AZ fails or lags, commits must cross the WAN link to the remote witness—turning sub-millisecond local replication into 45 ms+ round-trip write latency.
How can distributed systems architects enforce monotonic fencing, lease safety, and pre-vote protections so that physical cloud partitions cannot cause split-brain writes or election thrashing?
Options Considered
| Option | What It Gets Right | Where It Breaks | Verdict |
|---|---|---|---|
| Wall-clock leader leases only | Eliminates quorum round-trip on linearizable reads. | NTP adjustments or hypervisor VM pauses let old and new leaders hold overlapping leases. | Rejected — unsafe under clock/VM stalls. |
| Odd quorum + Raft Pre-Vote only | Stops isolated followers from bumping terms and disrupting healthy leaders. | Does not fence an already-elected zombie leader writing to shared storage or serving stale reads. | Partial — necessary, not sufficient. |
| Cloud API STONITH only | Physically detaches ENIs or stops partitioned instances via AWS/Azure APIs. | Control-plane API rate limits or 30s–45s execution lag leave a wide zombie write window. | Partial — use as asynchronous backstop. |
| Defense-in-depth (Pre-Vote + monotonic lease + storage epoch token) | Rejects stale writes synchronously at the storage boundary regardless of VM pauses or API lag. | Requires storage engine or shared block layer to enforce monotonic epoch comparison. | Chosen — closes the zombie window. |
Wall-clock leases alone fail whenever a VM pauses longer than the lease duration. Cloud API STONITH is valuable for cleaning up partitioned hosts, but control-plane APIs are asynchronous and slow under regional stress. Combining Raft Pre-Vote, conservative monotonic self-fencing, and storage-layer fencing tokens closes both election churn and stale-write windows.
The Fencing and Quorum Architecture
Surviving split-brain requires decoupling logical leader election from external storage mutation. Every write reaching persistent storage must carry a monotonically increasing fencing token verified by the storage guard.
1. The Pre-Vote Protocol: Neutralizing Asymmetric Partitions
In Raft (Section 9.6 of Diego Ongaro’s thesis), Pre-Vote adds a non-disruptive PreCandidate check before a node increments its term:
- When a follower’s election timeout expires, it enters
PreCandidatestate without incrementingcurrentTerm. - It sends a
PreVoteRPC asking peers whether they would grant a vote atTerm + 1. - Peers reject the
PreVoteif they are actively receiving heartbeats from a healthy leader within their election timeout. - Only if a majority responds affirmatively does the node increment its term and start a real election.
In etcd, --pre-vote (ETCD_PRE_VOTE) defaults to 'true', preventing an asymmetrically partitioned follower from forcing leader stepdowns when its packets reach the cluster.
2. Monotonic Fencing Tokens at the Storage Boundary
Following Martin Kleppmann’s fencing-token model, each leader election produces a strictly monotonically increasing epoch (for example, the Raft term). Every write sent to shared storage or a replication log carries that epoch, and the storage controller rejects any request with an epoch lower than the highest epoch it has already observed:
// Monotonic Storage Fencing Guard in Go
type StorageController struct {
mu sync.Mutex
currentEpoch uint64
}
type WriteRequest struct {
EpochToken uint64
Key string
Payload []byte
}
func (sc *StorageController) CommitWrite(ctx context.Context, req WriteRequest) error {
sc.mu.Lock()
defer sc.mu.Unlock()
if req.EpochToken < sc.currentEpoch {
return fmt.Errorf("FENCING VIOLATION: stale token %d < active epoch %d",
req.EpochToken, sc.currentEpoch)
}
if req.EpochToken > sc.currentEpoch {
sc.currentEpoch = req.EpochToken
}
return sc.persistToDisk(req.Key, req.Payload)
}
If Leader 1 (Epoch 4) is partitioned and AZ2/AZ3 elect Leader 2 (Epoch 5), the first write from Leader 2 advances currentEpoch to 5. Any delayed or in-flight write from Leader 1 carrying Epoch = 4 fails synchronously with a fencing error, even if Leader 1 never receives a STONITH signal.
3. Monotonic Clocks and Leader Lease Safety
For local read leases, consensus engines measure elapsed lease time with CLOCK_MONOTONIC_RAW rather than wall-clock gettimeofday(), avoiding NTP slew or backward clock steps. When a leader receives quorum heartbeats at monotonic tick $M_{\text{start}}$, it computes:
$$M_{\text{expire}} = M_{\text{start}} + \Delta_{\text{lease}} - \Delta_{\text{clock_drift_bound}}$$
If CLOCK_MONOTONIC_RAW reaches $M_{\text{expire}}$ before the next heartbeat quorum completes, the leader proactively self-fences: it stops serving local reads and steps down. Because a full VM freeze pauses CLOCK_MONOTONIC_RAW too, storage-level epoch tokens remain the non-negotiable backstop for writes.
4. Membership Changes: Single-Server vs. Joint Consensus
Even with Pre-Vote and storage fencing, changing cluster membership carelessly can violate quorum intersection. If an operator adds two new nodes to a 3-node cluster in a single step ($C_{\text{old}} = {1,2,3} \to C_{\text{new}} = {1,2,3,4,5}$), nodes that have not yet received the configuration log entry still treat any 2 of ${1,2,3}$ as a majority while updated nodes treat any 3 of ${1,2,3,4,5}$ (for example, ${3,4,5}$) as a majority—creating two disjoint majorities that can elect two leaders in the same term. Safe implementations either restrict changes to one voting member at a time (where every $N \to N \pm 1$ majority overlaps by at least one node) or use Raft Joint Consensus ($C_{\text{old,new}}$), which requires majorities from both the old and new configurations before committing $C_{\text{new}}$.
How It Rolls Out
Hardening an existing consensus cluster requires verifying topology, flags, and partition behavior in four stages without dropping quorum:
- Phase 1 — Topology and Quorum Audit: Verify every consensus cluster has an odd node count ($N = 2F + 1$, typically 3 or 5) spread across at least three physically distinct Availability Zones, with the consensus WAL isolated from heavy analytical I/O. Rollback: none (read-only audit).
- Phase 2 — Pre-Vote and Lease Fortification: Confirm
--pre-vote=trueinetcdor Leader Leases (kv.range.leader_leases) in CockroachDB, ensuring read leases are fortified by Raft leadership rather than unguarded wall-clock timers. Rollback: revert dynamic cluster setting one parameter at a time. - Phase 3 — Asymmetric Partition Chaos in Staging: Use
iptablesin staging to drop packets unilaterally between Node 1 and Node 2 while keeping Node 1 connected to Node 3. Verify that term churn stays flat and that any in-flight write from a partitioned leader is rejected by the storage guard. Rollback: flushiptablesrules (iptables -F). - Phase 4 — Production Telemetry and Membership Discipline: Alert on Raft term increments per minute,
fdatasyncp99 disk latency, and learner/follower lag. Enforce single-node-at-a-time membership changes (or Raft Joint Consensus) so quorum reconfiguration never creates two disjoint majorities. Rollback: pause automated membership operators.
In Practice
The defense-in-depth patterns above map directly to documented production behavior in widely deployed consensus systems:
- etcd Pre-Vote and Timer Tuning: In
etcdv3.5+,--pre-vote(ETCD_PRE_VOTE) is enabled by default ('true'), implementing Section 9.6 of the Raft thesis so partitioned followers probe peers before incrementing their term.etcddefaults to a100 ms--heartbeat-intervaland a1000 ms--election-timeout(maintaining roughly a 10x ratio so transient packet jitter does not trigger elections), and requiresfdatasynclatency on the WAL disk to stay well below the election timeout so followers do not miss heartbeats while flushing log entries. - CockroachDB Range Leases and Leader Leases: CockroachDB’s replication layer originally used expiration-based leases (still used for
metaandsystembootstrap ranges and lease transfers) and epoch-based leases tied to node liveness records. Because pure epoch-based leases could still allow a leader-leaseholder split if a leaseholder’s Raft log lagged, modern CockroachDB defaults to Leader Leases (kv.range.leader_leases), requiring the leaseholder to also be the up-to-date Raft leader before serving reads or coordinating writes. - Kleppmann’s Fencing Token Principle: As Martin Kleppmann documented in his analysis of distributed locks and leases, process pauses (GC, VM live migration,
SIGSTOP) can freeze any software timer—making monotonic storage-side epoch checks the only deterministic guard against zombie writes. - CARL Acknowledgment: I have not operated a hardware-accelerated RDMA consensus cluster personally; the operational guidance here is derived from documented
etcd, CockroachDB, and Raft specifications rather than private production telemetry.
Where It Breaks
| Condition | Breaks How | Detect | Mitigate |
|---|---|---|---|
| Even-numbered 4-node cluster | 2 nodes per zone across 2 AZs; losing 1 AZ leaves 2/4 (50%), which is not a majority. | Cluster freezes on single-AZ loss despite 4 nodes. | Deploy odd-numbered clusters ($2F+1$) across $\ge 3$ AZs; 4 nodes has the same fault tolerance as 3. |
| Witness co-located with primary | Node 1 and Witness in AZ1, Node 2 in AZ2; losing AZ1 drops 2/3 votes. | Quorum loss on single-AZ outage. | Place the witness in a physically distinct third AZ or failure domain. |
| Slow cloud API STONITH | Cloud API takes 30s–45s to detach ENI or stop partitioned instance. | Zombie node stays reachable during API lag window. | Combine async cloud STONITH with local self-fencing and synchronous storage epoch tokens. |
| Asymmetric flapping link | 30% packet loss triggers repeated elections and term increments. | Rapidly rising Raft term counter and leader change alerts. | Enable Raft Pre-Vote (--pre-vote=true) and tune election timeout backoff. |
| VM freeze / GC pause | Guest OS and CLOCK_MONOTONIC_RAW freeze during hypervisor migration. | Stale-lease read or write attempt after VM resumes. | Enforce storage-side monotonic epoch validation on every write. |
| Consensus WAL disk contention | Analytical queries share disk with Raft WAL; fdatasync spikes to 200 ms. | High wal_fsync_duration_seconds p99 and missed heartbeats. | Isolate consensus WAL onto dedicated NVMe or provisioned-IOPS volumes. |
| Dual-node reconfig during partition | Adding 2 nodes at once to a 3-node cluster creates two disjoint majorities. | Conflicting cluster membership views across nodes. | Perform single-node membership changes only, or use Raft Joint Consensus. |
Key Takeaways
- Quorum intersection does not fence zombie processes: An isolated old leader can still serve stale local reads or issue writes until its lease expires and storage rejects its epoch.
- Never deploy an even-numbered consensus cluster: A 4-node cluster requires 3 votes for a majority and tolerates only 1 failure—the exact same fault tolerance as a 3-node cluster, with worse write fan-out.
- Enable Raft Pre-Vote on every cluster: Pre-Vote (
--pre-vote=trueinetcd) stops asymmetrically partitioned followers from inflating cluster terms and forcing healthy leaders to step down. - Monotonic clocks do not survive VM pauses:
CLOCK_MONOTONIC_RAWprotects against NTP slew, not hypervisor freezes; only storage-layer monotonic epoch tokens prevent zombie writes. - Isolate the consensus WAL disk: Heartbeat stability depends on predictable
fdatasynclatency; never share the Raft WAL volume with heavy analytical queries or unthrottled compaction.
What to Do Next
- Problem: Audit your consensus clusters (
etcd, CockroachDB, Patroni/Consul, Kafka KRaft) for even-numbered node counts, co-located witnesses, or shared WAL storage. - Solution: Enforce odd-numbered ($2F+1$) placement across 3+ failure domains, enable Raft Pre-Vote, and require storage-boundary epoch validation alongside monotonic leader leases.
- Proof: Check
etcdflags (--pre-vote), CockroachDB range lease configuration, andwal_fsync_duration_secondsp99 metrics under peak load. - Action: This week, run an asymmetric
iptablespartition test in staging (drop traffic between Node 1 and Node 2 while leaving Node 1 to Node 3 open) and verify zero term-churn storms and zero divergent writes.
Sources
- Diego Ongaro & John Ousterhout — In Search of an Understandable Consensus Algorithm (Raft) and Ongaro’s Dissertation Section 9.6 (raft.github.io)
- Martin Kleppmann — How to do distributed locking (Fencing Tokens & Process Pauses) (martin.kleppmann.com)
etcdv3.5 Configuration Guide —--pre-voteFlag and Quorum Sizing (etcd.io/docs/v3.5/op-guide/configuration/)- CockroachDB Architecture — Replication Layer: Expiration-Based, Epoch-Based, and Leader Leases (cockroachlabs.com/docs/stable/architecture/replication-layer)