Monedula

Kafka troubleshooting

Partitions are offline with no leader

Kafka symptom

A partition is offline when it has no leader, so it serves no reads and no writes. That happens when every replica allowed to lead it is down (with unclean leader election off, only in-sync or eligible leader replicas qualify) or when the KRaft controller quorum has lost its majority and cannot elect anyone. Bring back a broker from the partition's last ISR or restore the controller quorum; an unclean election is the last resort and loses data.

Reproduce it in the playground

The moment it happensbroker-2 killed - partition OFFLINE. t+21.000s

ISR is empty. With unclean election disabled, Kafka refuses to promote the stale broker-3: durable, but unavailable.

Open at this step: step 5, broker-2 killed - partition OFFLINE

What it means

Partition leaders are chosen by the active controller. When a leader fails, the controller elects another replica from the ISR, so committed records survive the failover. If no ISR member is alive, Kafka by default waits for one to return rather than promote a replica that may be missing committed records. Until then kafka-topics.sh --describe shows Leader: none for the partition, the controller metric OfflinePartitionsCount is above zero, metadata requests return LEADER_NOT_AVAILABLE for it, and producers hold its records until delivery.timeout.ms expires and then fail them with "Expiring 1 record(s) for orders-0:120001 ms has passed since batch creation". Kafka also tracks Eligible Leader Replicas (KIP-966; per the Kafka 4.3 docs, on by default for clusters created with 4.1 or later): replicas outside the ISR that are safe to lead because the high watermark cannot advance while the ISR is below min.insync.replicas. When the ISR is empty, the controller may elect one of them, and after that the last known leader if it comes back.

Likely causes, most common first

  1. Every in-sync replica is down. Two or three broker failures can take out every member of a partition's ISR, especially when followers had already dropped out of it before the leader died. With unclean.leader.election.enable=false, the default, the out-of-sync survivors are not allowed to lead, so the partition stays offline.
  2. Every replica is down. A topic with replication factor 1 goes offline whenever its only broker does, and topics are created that way when default.replication.factor is left at its default of 1. Replicas placed in one rack or zone go down together.
  3. The controller quorum has lost its majority. In KRaft, elections need an active controller, and the controller quorum stays available only while a majority of controllers is alive: 3 controllers tolerate one failure, 5 tolerate two. Without a majority, a partition whose leader dies gets no new leader, even if healthy replicas exist.
  4. Brokers are running but fenced. A broker counts as alive only while it heartbeats to the controller within broker.session.timeout.ms (9 seconds by default). A broker that cannot reach the controllers, after a network split or with a wrong controller listener, is not eligible to lead.

How to fix it

What not to do

Configs involved

Reproduce it in the simulator

Sources

Related

All troubleshooting pages