On this page
Kafka Improvement Proposal
KIP-890: the broker defends transactions, transaction version 2
KIP-890 made the broker check transactional writes instead of trusting the producer. Part one (Kafka 3.6) rejects a write to a partition that was never added to the transaction, which caused hanging transactions. Part two (Kafka 4.0) bumps the producer epoch on every commit and abort, so a late write from an earlier transaction can no longer land in the next one.
- Proposal
- KIP-890, Transactions Server-Side Defense
- Status
- Shipped Part 1 in Kafka 3.6 (2023), part 2 in Kafka 4.0 (2025) as transaction.version 2.
- Area
- Producers and transactions
- Proposal page
- KIP-890 on the Apache Kafka wiki
Why it was needed
A hanging transaction is one the coordinator thinks is finished while a partition still holds its open records. It pins the last stable offset, so read_committed consumers stop and compaction cannot clean past it, until someone aborts it by hand. The usual cause was a retried or delayed produce request arriving after the client had moved on.
What it changes
With part one the leader asks the transaction coordinator to verify that the partition is in the ongoing transaction before it appends, so a stray write is refused. Part two, the new transaction protocol, adds partitions to the transaction implicitly on the server and bumps the producer epoch at the end of each transaction, which fences any request still in flight from the previous one. Older clients that break the rules get INVALID_TXN_STATE.
How to use it
- Part one is on by default (transaction.partition.verification.enable=true) on brokers from 3.6; use 3.6.1 or newer, since 3.6.0 had a bug with compression.
- Part two needs the transaction.version=2 feature, enabled when a cluster finishes its upgrade to 4.0, and producers on Kafka 4.0 or newer clients.
Where it stands
Part one shipped in Kafka 3.6 for data partitions and was extended to consumer-offset partitions in 3.7. Part two completed in Kafka 4.0 and is the default for clusters that finished upgrading to 4.0; producers switch to it at their next transaction, without a restart.
What comes next
Follow-up KIPs refine error handling, such as KIP-1050 with a TransactionAbortableException, and Kafka 4.2 carried the transaction version into transaction markers (KIP-1228). Two-phase commit with external systems is a separate proposal.
See it in the simulator
- Kafka zombie producer fencing with transactional.id (EOS - offsets in a txn + fencing) Step 7: zombie fenced Open at this step: Kafka zombie producer fencing with transactional.id
- Kafka transaction.timeout.ms: the coordinator aborts (Transaction timeout) Step 3: Timed out · auto-aborted Open at this step: Kafka transaction.timeout.ms: the coordinator aborts
Sources
- KIP-890: Transactions Server-Side Defense
- Apache Kafka 4.4: transaction protocol
- Apache Kafka 4.0.0 release announcement