Repository navigation
Fix infinite pause with async acks on transactional topics - #4265
Closed
RAJESHREDDY0508 wants to merge 1 commit into
Closed
RAJESHREDDY0508 wants to merge 1 commit into
RAJESHREDDY0508 wants to merge 1 commit into
Conversation
The ackInOrder method in KafkaMessageListenerContainer assumed contiguous offsets when processing deferred acknowledgments. However, with transactional producers and read_committed isolation, Kafka inserts transaction control records that create gaps in the offset sequence (e.g., 0, 2, 4, 6 instead of 0, 1, 2, 3). When async acknowledgments arrived out of order, the buggy logic would check if the next deferred offset equals current offset + 1. This check failed with non-contiguous offsets, causing the consumer to pause indefinitely waiting for acknowledgments that would never be processed. Changed the logic to check if the next deferred offset exists in the batch's offset list, rather than checking for sequential offsets. This correctly handles transaction control records and any other scenarios where Kafka creates offset gaps. Fixes spring-projects#4258
Contributor
|
@RAJESHREDDY0508 Looks like this PR is a duplicate of #4264. |
Author
|
Thanks for pointing that out, Soby. I see that #4264 already addresses the same issue. |
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.
The ackInOrder method in KafkaMessageListenerContainer assumed contiguous offsets when processing deferred acknowledgments. However, with transactional producers and read_committed isolation, Kafka inserts transaction control records that create gaps in the offset sequence (e.g., 0, 2, 4, 6 instead of 0, 1, 2, 3).
When async acknowledgments arrived out of order, the buggy logic would check if the next deferred offset equals current offset + 1. This check failed with non-contiguous offsets, causing the consumer to pause indefinitely waiting for acknowledgments that would never be processed.
Changed the logic to check if the next deferred offset exists in the batch's offset list, rather than checking for sequential offsets. This correctly handles transaction control records and any other scenarios where Kafka creates offset gaps.
Fixes #4258