kafka
runtime_error
ai_generated
partial
org.apache.kafka.common.errors.TransactionalIdExpiredException:事务 ID 已过期并被隔离
org.apache.kafka.common.errors.TransactionalIdExpiredException: The transactional id has expired and is now fenced
ID: kafka/transactional-id-expired
92%修复率
88%置信度
1证据数
2024-06-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.6.0 | active | — | — | — |
| 3.7.1 | active | — | — | — |
| 3.8.0 | active | — | — | — |
根因分析
事务 ID 在 transaction.max.timeout.ms 窗口内未被使用,导致协调器将其隔离。
English
The transactional.id has not been used within the transaction.max.timeout.ms window, causing the coordinator to fence it.
官方文档
https://kafka.apache.org/documentation/#brokerconfigs_transaction.max.timeout.ms解决方案
-
Use a new transactional.id for the producer, e.g., in Java: props.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, "new-app-id-" + System.currentTimeMillis()); Then initTransactions() and begin transaction.
-
Increase transaction.max.timeout.ms on the broker: kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-default --alter --add-config transaction.max.timeout.ms=900000 And ensure the producer uses a lower transaction.timeout.ms.
无效尝试
常见但无效的做法:
-
98% 失败
Restarting the producer does not recover the expired transactional.id; it remains fenced.
-
80% 失败
Increasing transaction.timeout.ms on the producer alone does not retroactively prevent expiration.