Repository navigation
KAFKA-21132: Bound the transaction abort in producer close() by transaction.timeout.ms - #23857
Open
ojasvajain wants to merge 2 commits into
Open
ojasvajain wants to merge 2 commits into
ojasvajain wants to merge 2 commits into
Conversation
…action.timeout.ms When a producer is closed with an open transaction, the sender thread aborts it and retries the EndTxn request until it succeeds. If the transaction coordinator is unreachable or keeps returning retriable errors, this never ends, so close() without a timeout blocks indefinitely. The coordinator expires a transaction after transaction.timeout.ms anyway, so stop retrying the abort after that long. The clock starts when the abort starts, so other work done while closing does not count against it. Waiting for the coordinator node to become ready is capped at the remaining time, so the deadline is not overshot by request.timeout.ms. This applies to both close() and close(Duration): the sender stops itself at the deadline, and a bounded close still force closes at its own timeout, whichever comes first.
ojasvajain
marked this pull request as draft
October 18, 2026 13:37
ojasvajain
marked this pull request as ready for review
October 19, 2026 12:48
…t and KafkaProducerTest
ojasvajain
force-pushed
the
KAFKA-21132-producer-close-abort-timeout
branch
from
October 19, 2026 18:01
da2610b to
e590fa4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a producer is closed with an open transaction, the sender thread aborts it and retries the EndTxn request until it succeeds. If the transaction coordinator is unreachable or keeps returning retriable errors, this never ends, so close() without a timeout blocks indefinitely.
Fix
The coordinator expires a transaction after transaction.timeout.ms anyway, so stop retrying the abort after that long. The clock starts when the abort starts, so other work done while closing does not count against it. Waiting for the coordinator node to become ready is capped at the remaining time, so the deadline is not overshot by request.timeout.ms.
This applies to both close() and close(Duration): the sender stops itself at the deadline, and a bounded close still force closes at its own timeout, whichever comes first.