Kafka Error INVALID_PRODUCER_ID_MAPPING
Error code 49 · Non-retriable Producer
The producer attempted to use a producer id which is not currently assigned to its transactional id.
Common Causes
- Producer is using a producer ID that was originally assigned to a different transactional.id — can happen after a crash and incorrect recovery
- Transaction log was compacted or the coordinator lost state, and the producer ID to transactional ID mapping is no longer valid
- Producer is retrying with a stale producer ID after the transaction coordinator migrated to a different broker and lost in-memory state
Solutions
- Close the current producer and call initTransactions() on a new KafkaProducer instance to get a fresh, valid producer ID assignment
- Check the health of the __transaction_state topic — ensure it has enough replicas and is not under-replicated
- Ensure transaction.state.log.min.isr and transaction.state.log.replication.factor are set to values that survive broker failures
Diagnostic Commands
# Inspect __transaction_state topic health
kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic __transaction_state 2>&1
# Look for corruption or validation errors
grep 'INVALID_PRODUCER_ID_MAPPING\|InvalidProducerIdMapping\|producer id mapping' /var/log/kafka/server.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.