kafka
runtime_error
ai_generated
true
org.apache.kafka.common.errors.PartitionNotAssignedException:分区my-topic-0未分配给此消费者实例
org.apache.kafka.common.errors.PartitionNotAssignedException: Partition my-topic-0 is not assigned to this consumer instance
ID: kafka/partition-not-assigned
85%修复率
86%置信度
1证据数
2023-09-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| kafka 2.8.0 | active | — | — | — |
| kafka 3.0.0 | active | — | — | — |
| kafka 3.3.0 | active | — | — | — |
根因分析
消费者尝试提交偏移或获取未分配给它的分区的数据,通常是由于再平衡后分区分配过期。
English
The consumer attempted to commit offsets or fetch data for a partition that was not assigned to it, often due to a stale partition assignment after a rebalance.
官方文档
https://kafka.apache.org/documentation/#consumerconfigs_session.timeout.ms解决方案
-
Use a ConsumerRebalanceListener to update partition assignments after a rebalance, and ensure commitSync() is only called for assigned partitions.
-
Increase 'session.timeout.ms' and 'heartbeat.interval.ms' to reduce the likelihood of spurious rebalances that cause stale assignments.
无效尝试
常见但无效的做法:
-
60% 失败
poll() may not trigger a rebalance if the group is stable; it can also cause a busy loop that degrades performance.
-
75% 失败
This bypasses the group coordinator and can lead to offset conflicts or duplicate consumption if other consumers exist.