Skip to content

Fix infinite pause with async acks on transactional topics - #4265

Closed
RAJESHREDDY0508 wants to merge 1 commit into
spring-projects:mainfrom
RAJESHREDDY0508:fix-4258-async-ack-gap
Closed

RAJESHREDDY0508 wants to merge 1 commit into
spring-projects:mainfrom
RAJESHREDDY0508:fix-4258-async-ack-gap

Conversation

@RAJESHREDDY0508

Copy link
Copy Markdown

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

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
@sobychacko

Copy link
Copy Markdown
Contributor

@RAJESHREDDY0508 Looks like this PR is a duplicate of #4264.

@RAJESHREDDY0508

Copy link
Copy Markdown
Author

Thanks for pointing that out, Soby.

I see that #4264 already addresses the same issue.
I’ll close this PR and follow the other approach instead.
Appreciate the quick review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consumer was paused infinitely since difference in async ack offsets is larger than 1

2 participants