LEADER_NOT_AVAILABLE communication runtime_error ai_generated true

LEADER_NOT_AVAILABLE: No leader for partition N in topic X

ID: communication/kafka-leader-not-available

Also available as: JSON · Markdown · 中文
85%Fix Rate
88%Confidence
1Evidence
2023-08-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Kafka 3.4 active
Kafka 3.5 active
Kafka 3.6 active

Root Cause

The Kafka broker that was the leader for a partition has crashed or is unreachable, and the controller has not yet elected a new leader via ISR (In-Sync Replicas).

generic

中文

Kafka 分区领导者代理已崩溃或不可达,控制器尚未通过 ISR 选举出新领导者。

Official Documentation

https://kafka.apache.org/documentation/#broker_failures

Workarounds

  1. 85% success Run `kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type preferred --topic X --partition N` to trigger a clean leader election from ISR.
    Run `kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type preferred --topic X --partition N` to trigger a clean leader election from ISR.
  2. 70% success Increase `unclean.leader.election.enable=true` in broker config to allow out-of-sync replicas to become leader as a last resort, then revert.
    Increase `unclean.leader.election.enable=true` in broker config to allow out-of-sync replicas to become leader as a last resort, then revert.

中文步骤

  1. Run `kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type preferred --topic X --partition N` to trigger a clean leader election from ISR.
  2. Increase `unclean.leader.election.enable=true` in broker config to allow out-of-sync replicas to become leader as a last resort, then revert.

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Restarting the failed broker may cause split-brain if not cleanly shut down; leader election still fails.

  2. 70% fail

    Increasing replication factor doesn't fix immediate leader unavailability; requires reconfiguration.

  3. 40% fail

    Manually setting preferred leader via kafka-leader-election.sh can cause data inconsistency if ISR is out of sync.