[BUG-447] Idempotency bug: OOO loop when response is lost but subsequent batches succeed#448
Merged
luoyuxia merged 2 commits intoapache:mainfrom Mar 21, 2026
Conversation
…bsequent batches succeed
Contributor
Author
Contributor
There was a problem hiding this comment.
Nice catch and thank you for the PR!
I think this will be challenging to test (manually), is there a way to reproduce this to ensure that the change works? Curious about how this was detected in the first place.
Does Java side need the same change given that we mostly base on Java implementation?
Nvm: just saw Java side's Pr. TY.
Contributor
Author
|
@leekeiabstraction Ty for the review, there is unit test that checks this scenario, also updated comment. |
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.
Summary
closes #447
Fix idempotent writer infinite retry on OutOfOrderSequenceException when response is lost
When a batch response is lost (e.g. timeout) but the server committed it, and subsequent higher-sequence batches are acked, retrying the original batch causes the server to return OutOfOrderSequenceException. The client's
!is_nextretry heuristic incorrectly treats this as retriable, looping until retries exhaust and then failing a successfully committed batch.Kafka deals with it at the protocol level with epoch bumping, we don't need here, so we fix at the client level.
Fix: before checking
can_retry, if the batch sequence <= last_acked_sequence, complete it as success - a higher-sequence ack guarantees the batch was committed (server enforces sequential ordering).Backport of apache/fluss#2827