conduktor.io ↗

Kafka Exception ProducerFencedException

org.apache.kafka.common.errors.ProducerFencedException
Non-retriable Transactions

This fatal exception indicates that another producer with the same transactional.id has been started. It is only possible to have one producer instance with a transactional.id at any given time, and the latest one to be started "fences" the previous instances so that they can no longer make transactional requests. When you encounter this exception, you must close the producer instance.

Common Causes

Solutions

Example Stack Trace

org.apache.kafka.common.errors.ProducerFencedException: There is a newer producer with the same transactionalId which fences the current one.

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 -20

Related

Protocol error: PRODUCER_FENCED (code 90)

Related Transactions exceptions: ConcurrentTransactionsException · InvalidTxnStateException

Hitting ProducerFencedException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.