# org.apache.kafka.common.errors.TransactionalIdExpiredException: The transactional id has expired and is now fenced

- **ID:** `kafka/transactional-id-expired`
- **Domain:** kafka
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

The transactional.id has not been used within the transaction.max.timeout.ms window, causing the coordinator to fence it.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.6.0 | active | — | — |
| 3.7.1 | active | — | — |
| 3.8.0 | active | — | — |

## Workarounds

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.** (95% success)
   ```
   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.** (90% success)
   ```
   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.
   ```

## Dead Ends

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