-
Notifications
You must be signed in to change notification settings - Fork 1.7k
GH-2581: Fix OOO Commits with Rebalance #2586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Resolves spring-projects#2581 If a rebalance occurred while pending out of order commits were present, the pending commits were correctly purged, however, the `consumerPaused` boolean remained true. This prevented the consumer from being paused again while the next batch of records is being processed and subsequent polls returned more records. Reset the `consumerPaused` boolean when all pending commits are purged. Also, with a cooperative assignor, ensure that any newly assigned partitions are paused if pending commits are present. Add tests to verify the correct behavior with a legacy and cooperative assignor. Also tested with the reporter's reproducer. **cherry-pick to 2.9.x**
...ng-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java
Outdated
Show resolved
Hide resolved
|
||
@SuppressWarnings({ "unchecked", "rawtypes" }) | ||
@Test | ||
void pruneRevokedPartitionsFromPendingOutOfOrderCommitsLegacyAssignor() throws InterruptedException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gary, I don't see any Assignor
settings in the test code.
How does it work, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's simulated.
With a legacy assignor, all current assignments are revoked and all (or a subset) are re-assigned. With a coop assignor, only a subset are revoked and (possibly) previously unassigned partitions might be assigned.
See the case 1:
poll phases in both tests - that is where the simulation is. In the coop case, I test that consumer.pause()
is called twice (once for the original assignments and once for the newly assigned partition).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool. Thank you!
Co-authored-by: Artem Bilan <abilan@vmware.com>
...ng-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java
Outdated
Show resolved
Hide resolved
Cherry-picked as c8088ef after some conflict fixes. |
Resolves #2581
If a rebalance occurred while pending out of order commits were present, the pending commits were correctly purged, however, the
consumerPaused
boolean remained true.This prevented the consumer from being paused again while the next batch of records is being processed and subsequent polls returned more records.
Reset the
consumerPaused
boolean when all pending commits are purged.Also, with a cooperative assignor, ensure that any newly assigned partitions are paused if pending commits are present.
Add tests to verify the correct behavior with a legacy and cooperative assignor.
Also tested with the reporter's reproducer.
cherry-pick to 2.9.x