# org.apache.kafka.common.errors.TransactionalIdExpiredException：事务 ID 已过期并被隔离

- **ID:** `kafka/transactional-id-expired`
- **领域:** kafka
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

事务 ID 在 transaction.max.timeout.ms 窗口内未被使用，导致协调器将其隔离。

## 版本兼容性

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

## 解决方案

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.
   ```

## 无效尝试

- **** — Restarting the producer does not recover the expired transactional.id; it remains fenced. (98% 失败率)
- **** — Increasing transaction.timeout.ms on the producer alone does not retroactively prevent expiration. (80% 失败率)
