Beginner5 min
Leader Failover Recovery
See what happens to a producer when the leader of the partition it writes to stops.
When a partition's leader stops, the controller elects a new leader from the partition's in-sync replicas. A producer that still has the old leader in its metadata gets a retriable error such as NOT_LEADER_OR_FOLLOWER, refreshes its metadata, and retries. This lab walks through that cycle.
The steps use the simulator and name the control to use. The outcomes they describe are what the simulator models; the sources below are what Apache documents.
Steps
0 of 6 steps completed
Verification
Every partition's ISR is back to three brokers, and the messages you sent are on P2.
The interview angle
A new leader is elected from the ISR, and clients refresh their metadata and retry. With enable.idempotence=true, the default, a retry within the same producer session does not write a duplicate.
Sources
- Design (4.2 documentation) (opens in a new tab)
- Protocol and error codes (4.2 documentation) (opens in a new tab)
- Producer configs (4.2 documentation) (opens in a new tab)
- AbstractFetcherThread.scala (4.2 source) (opens in a new tab)
Checked against Kafka 4.2 documentation on 11 October 2026. Draft: not yet reviewed by a Kafka specialist, and releases move on, so confirm against the current documentation before you act on it.