kafka network_error ai_generated partial

org.apache.kafka.common.errors.ZooKeeperConnectionLossException:KRaft控制器选举期间连接丢失

org.apache.kafka.common.errors.ZooKeeperConnectionLossException: Connection loss during KRaft controller election

ID: kafka/zookeeper-connection-loss-during-kraft-election

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
1证据数
2024-08-10首次发现

版本兼容性

版本状态引入弃用备注
Kafka 3.5.0 active
Kafka 3.6.0 active
Kafka 3.7.0 active

根因分析

在KRaft迁移或混合模式操作期间,ZooKeeper连接丢失中断了控制器选举过程,导致集群没有领导者。

English

During KRaft migration or mixed-mode operation, a ZooKeeper connection loss disrupts the controller election process, leaving the cluster without a leader.

generic

官方文档

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

解决方案

  1. Restart the KRaft controller process with 'bin/kafka-server-stop.sh && bin/kafka-server-start.sh config/kraft/server.properties' to force a new election.
  2. Ensure ZooKeeper quorum is stable and network latency between ZooKeeper and Kafka brokers is below 10ms. Use 'echo stat | nc zookeeper-host 2181' to check ZooKeeper state.

无效尝试

常见但无效的做法:

  1. Restarting only ZooKeeper servers 90% 失败

    Restarting ZooKeeper alone does not re-trigger the KRaft election; the controller process must be restarted.

  2. Raising zookeeper.session.timeout.ms 80% 失败

    Increasing ZooKeeper session timeout delays the failure but does not prevent connection loss due to network issues.