kafka network_error ai_generated true

org.apache.kafka.common.errors.TransactionCoordinatorNotAvailableException: The transaction coordinator is not available

ID: kafka/transaction-coordinator-not-available

Also available as: JSON · Markdown · 中文
82%Fix Rate
87%Confidence
1Evidence
2024-02-10First Seen

Root Cause

The broker acting as transaction coordinator for the transactional ID is down or unreachable.

generic

中文

作为事务ID的事务协调器的代理已关闭或不可达。

Official Documentation

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

Workarounds

  1. 85% success Check broker health and restart the coordinator broker if needed: systemctl restart kafka on the affected broker.
    Check broker health and restart the coordinator broker if needed: systemctl restart kafka on the affected broker.
  2. 70% success Increase transaction.timeout.ms to give the coordinator more time to recover, e.g., props.put("transaction.timeout.ms", "900000");
    Increase transaction.timeout.ms to give the coordinator more time to recover, e.g., props.put("transaction.timeout.ms", "900000");
  3. 80% success Wait for the coordinator to become available and retry the transaction with exponential backoff.
    Wait for the coordinator to become available and retry the transaction with exponential backoff.

中文步骤

  1. 检查代理健康状况,必要时重启协调器代理:在受影响的代理上执行 systemctl restart kafka。
  2. 增加 transaction.timeout.ms 以给协调器更多时间恢复,例如 props.put("transaction.timeout.ms", "900000");
  3. 等待协调器可用并使用指数退避重试事务。

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Restarting the application without ensuring the coordinator broker is healthy will retrigger the error.

  2. 85% fail

    Changing the transactional.id in config causes the producer to be fenced and lose transaction state.