Kafka Error PRODUCER_FENCED
Error code 90 · Non-retriable Transactions
There is a newer producer with the same transactionalId which fences the current one.
Common Causes
- A new producer instance was initialized with the same transactional.id, causing the broker to bump the producer epoch and fence all older instances with the same ID
- Producer application restarted (crash, rolling deploy) and created a new transactional producer before the old one was cleanly shut down
- Two independent application instances were accidentally configured with the same transactional.id, creating a conflict
Solutions
- Ensure transactional.id is unique per logical producer stream and that only one producer instance with that ID is active at a time — treat fencing as a correctness signal, not a bug
- On receiving PRODUCER_FENCED, do not retry with the same producer instance — create a new KafkaProducer with initTransactions() to get a fresh epoch
- Audit your deployment to guarantee no duplicate transactional.id values exist across instances; use a registry or naming convention based on partition assignment
Diagnostic Commands
# Inspect transaction-state topic health
kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic __transaction_state | grep -E 'Leader|Isr|Replicas'
# Look for producer epoch events in logs
grep 'ProducerFencedException\|producer fenced\|epoch' /var/log/app/*.log | tail -20Related APIs
This error can be returned by: AddOffsetsToTxn · AddPartitionsToTxn · EndTxn · InitProducerId
Debugging Kafka errors? Conduktor Console gives you real-time visibility into your cluster. Explore all errors in the Error Decoder.