LEADER_NOT_AVAILABLE
communication
runtime_error
ai_generated
true
LEADER_NOT_AVAILABLE: 主题 X 的分区 N 无领导者
LEADER_NOT_AVAILABLE: No leader for partition N in topic X
ID: communication/kafka-leader-not-available
85%修复率
88%置信度
1证据数
2023-08-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Kafka 3.4 | active | — | — | — |
| Kafka 3.5 | active | — | — | — |
| Kafka 3.6 | active | — | — | — |
根因分析
Kafka 分区领导者代理已崩溃或不可达,控制器尚未通过 ISR 选举出新领导者。
English
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).
官方文档
https://kafka.apache.org/documentation/#broker_failures解决方案
-
Run `kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type preferred --topic X --partition N` to trigger a clean leader election from ISR.
-
Increase `unclean.leader.election.enable=true` in broker config to allow out-of-sync replicas to become leader as a last resort, then revert.
无效尝试
常见但无效的做法:
-
50% 失败
Restarting the failed broker may cause split-brain if not cleanly shut down; leader election still fails.
-
70% 失败
Increasing replication factor doesn't fix immediate leader unavailability; requires reconfiguration.
-
40% 失败
Manually setting preferred leader via kafka-leader-election.sh can cause data inconsistency if ISR is out of sync.