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

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://kafka.apache.org/documentation/#brokerconfigs_transaction.max.timeout.ms

解决方案

  1. 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.
  2. 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.

无效尝试

常见但无效的做法:

  1. 98% 失败

    Restarting the producer does not recover the expired transactional.id; it remains fenced.

  2. 80% 失败

    Increasing transaction.timeout.ms on the producer alone does not retroactively prevent expiration.