Kafka Exception TransactionAbortedException
org.apache.kafka.common.errors.TransactionAbortedException
Non-retriable
Producer
This is the Exception thrown when we are aborting any undrained batches during a transaction which is aborted without any underlying cause - which likely means that the user chose to abort.
Common Causes
- The transaction was explicitly aborted by the application (producer.abortTransaction()), so buffered sends in that transaction fail with this exception
- The transaction timed out (transaction.timeout.ms elapsed) and was rolled back by the coordinator, so the records buffered in it fail with this exception (note: a fenced producer raises ProducerFencedException, not this)
- An error earlier in the transaction marked it for abort, so subsequent send() callbacks complete exceptionally
Solutions
- This is expected when you call abortTransaction() — handle the failed send callbacks and retry the whole transaction if appropriate
- If unexpected, check whether transaction.timeout.ms is too low for your transaction duration, or whether a second producer with the same transactional.id fenced this one
- Wrap the transaction in try/catch: on any abortable error, call abortTransaction() and restart the transaction
Example Stack Trace
org.apache.kafka.common.errors.TransactionAbortedException: Failing batch since transaction was abortedRelated
Related Producer exceptions: BufferExhaustedException · InvalidProducerEpochException · OutOfOrderSequenceException · RecordBatchTooLargeException · RecordTooLargeException · UnknownProducerIdException · UnsupportedForMessageFormatException
Hitting
TransactionAbortedException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.