conduktor.io ↗

Kafka Exception InvalidProducerEpochException

org.apache.kafka.common.errors.InvalidProducerEpochException
Non-retriable Producer

This exception indicates that the produce request sent to the partition leader contains a non-matching producer epoch. When encountering this exception, user should abort the ongoing transaction by calling KafkaProducer#abortTransaction which would try to send initPidRequest and reinitialize the producer under the hood.

Common Causes

Solutions

Example Stack Trace

org.apache.kafka.common.errors.InvalidProducerEpochException: Producer attempted to produce with an old epoch.

Diagnostic Commands

# Look for producer epoch events in logs grep 'INVALID_PRODUCER_EPOCH\|InvalidProducerEpoch\|producer epoch\|fenced' /var/log/kafka/server.log | tail -30 # Inspect transaction-state topic health kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic __transaction_state | grep -E 'Leader|Isr|Replicas'

Related

Protocol error: INVALID_PRODUCER_EPOCH (code 47)

Related Producer exceptions: BufferExhaustedException · OutOfOrderSequenceException · RecordBatchTooLargeException · RecordTooLargeException · TransactionAbortedException · UnknownProducerIdException · UnsupportedForMessageFormatException

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