# org.apache.kafka.common.errors.TransactionalCoordinatorFencedException：纪元5的事务协调器已被隔离

- **ID:** `kafka/transaction-coordinator-fenced`
- **领域:** kafka
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

新的事务协调器接管，由于领导者选举或代理故障而隔离了旧协调器。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| kafka 3.5.0 | active | — | — |
| kafka 3.6.2 | active | — | — |
| kafka 3.7.0 | active | — | — |

## 解决方案

1. ```
   Restart the transactional producer to re-initialize the coordinator connection: 'producer.initTransactions();' in code, or restart the application.
   ```
2. ```
   Ensure all brokers have consistent transaction.state.log.replication.factor and min.insync.replicas settings, then restart the broker with the highest epoch: 'bin/kafka-server-stop.sh && bin/kafka-server-start.sh config/server.properties'
   ```

## 无效尝试

- **** — Manually reassigning partitions without checking coordinator health causes repeated fencing. (85% 失败率)
- **** — Disabling idempotent producer to avoid fencing breaks exactly-once semantics and may cause duplicates. (70% 失败率)
