On this page
Kafka Improvement Proposal
KIP-966: Eligible Leader Replicas, a safe leader when the ISR is empty
KIP-966 lets Kafka elect a safe leader in cases where it used to have none. Because the high watermark only moves while the ISR has at least min.insync.replicas members, a replica that dropped out of the ISR at that point still holds every committed record. The controller now tracks those replicas as eligible leaders and can elect one when the ISR is empty.
- Proposal
- KIP-966, Eligible Leader Replicas
- Status
- Shipped Preview in Kafka 4.0; on by default for clusters created with 4.1 or later.
- Area
- Cluster and operations
- Proposal page
- KIP-966 on the Apache Kafka wiki
Why it was needed
When every ISR member was gone, Kafka had two bad options: keep the partition offline until an ISR member came back, or allow an unclean election and lose committed records. Yet often a replica that had just left the ISR was perfectly up to date; Kafka simply did not know it was safe.
What it changes
The controller stores, per partition, the replicas that left the ISR while it was below min.insync.replicas: the Eligible Leader Replicas. Election order becomes ISR first, then a live eligible replica, then the last known leader. ELR also makes min.insync.replicas a cluster-level setting, so a broker-level value can no longer be changed.
How to use it
- Clusters created with Kafka 4.1 or later have it on. On an upgraded cluster enable the eligible.leader.replicas.version=1 feature with kafka-features.sh; downgrading to 0 is safe.
- Watch the ElectionFromEligibleLeaderReplicasPerSec metric to see it at work.
Where it stands
Part one shipped as a preview in Kafka 4.0 and is enabled by default on new clusters since Kafka 4.1. The unclean recovery part of the KIP, a smarter replacement for unclean leader election, has not shipped.
What comes next
The remaining work is unclean recovery: a strategy for picking the replica with the most data when no safe one is left. Deprecating unclean.leader.election.enable waits on it.
See it in the simulator
- Kafka Eligible Leader Replicas (KIP-966) in action (Eligible leader replicas (KIP-966)) Step 6: broker-2 elected from the ELR - clean, no data loss Open at this step: Kafka Eligible Leader Replicas (KIP-966) in action
- Kafka unclean leader election: permanent loss of acked data (Unclean election: permanent data loss) Step 5: broker-2 killed - stale broker-3 promoted UNCLEAN, committed records lost Open at this step: Kafka unclean leader election: permanent loss of acked data
- Watch Kafka unclean.leader.election.enable in a simulation (Unclean leader) Step 5: broker-2 killed - partition OFFLINE Open at this step: Watch Kafka unclean.leader.election.enable in a simulation
Scenario 03.2.6 turns ELR on and shows a replica outside the ISR elected with no data loss; 03.2.4 and 03.2.3 show the dilemma without it. ELR is on only in that scenario: free play and the others keep the pre-4.1 rules. The simulator picks the first live ELR member in assignment order, treats a hard kill as an unclean shutdown, and leaves out the last-known-leader step.