# 事务超时异常：事务协调器因超时已中止事务

- **ID:** `kafka/transaction-abort-timeout`
- **领域:** kafka
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Kafka事务超过了配置的max.transaction.timeout.ms，导致协调器中止事务以释放资源。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Kafka 3.6.0 | active | — | — |
| Kafka 3.7.1 | active | — | — |

## 解决方案

1. ```
   Increase `max.transaction.timeout.ms` in broker config (e.g., to 300000) and restart broker, then set producer's `transaction.timeout.ms=120000`.
   ```
2. ```
   Optimize transaction logic to complete within the default 60000ms by batching fewer records or reducing external calls.
   ```
3. ```
   Example broker config: `transaction.max.timeout.ms=300000` in server.properties, then producer config: `props.put(ProducerConfig.TRANSACTION_TIMEOUT_CONFIG, 120000);`
   ```

## 无效尝试

- **** — The broker's max.transaction.timeout.ms overrides the producer setting, so the timeout still applies. (75% 失败率)
- **** — It is not a fix; it changes the application's semantics and may cause duplicate writes. (60% 失败率)
