Skip to content

KAFKA-21132: Bound the transaction abort in producer close() by transaction.timeout.ms - #23857

Open
ojasvajain wants to merge 2 commits into
apache:trunkfrom
ojasvajain:KAFKA-21132-producer-close-abort-timeout
Open

ojasvajain wants to merge 2 commits into
apache:trunkfrom
ojasvajain:KAFKA-21132-producer-close-abort-timeout

Conversation

@ojasvajain

@ojasvajain ojasvajain commented Oct 18, 2026 •

Copy link
Copy Markdown

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.

…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.
@github-actions github-actions Bot added triage PRs from the community producer clients labels Oct 18, 2026
@ojasvajain
ojasvajain marked this pull request as draft October 18, 2026 13:37
@ojasvajain
ojasvajain marked this pull request as ready for review October 19, 2026 12:48
@Nikita-Shupletsov Nikita-Shupletsov added ci-approved and removed triage PRs from the community labels Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants