[fix][client] Prevent epoch race in MultiTopicsConsumer batch receive#25210
Open
ChimdumebiNebolisa wants to merge 9 commits intoapache:masterfrom
Open
[fix][client] Prevent epoch race in MultiTopicsConsumer batch receive#25210ChimdumebiNebolisa wants to merge 9 commits intoapache:masterfrom
ChimdumebiNebolisa wants to merge 9 commits intoapache:masterfrom
Conversation
|
@ChimdumebiNebolisa Please add the following content to your PR description and select a checkbox: |
fa110d7 to
9602f5c
Compare
5ed0fda to
a83cb0d
Compare
3 tasks
| @@ -0,0 +1,185 @@ | |||
| # Investigation: GitHub issue #25204 – MultiTopicsConsumer receives message with older ConsumerEpoch after redeliverUnacknowledgedMessages() | |||
Contributor
There was a problem hiding this comment.
You should not commit the investigation document to the code base. You can post it to Gist and share the link in the PR description
pulsar-client/src/test/java/org/apache/pulsar/client/impl/MultiTopicsConsumerEpochRaceTest.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/test/java/org/apache/pulsar/client/impl/MultiTopicsConsumerEpochRaceTest.java
Outdated
Show resolved
Hide resolved
Author
|
Thanks for the review. I’ve updated the test to address the feedback:
The remaining reflection is only for private members with no stable test seam ( |
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.
Fixes #25204
Motivation
MultiTopicsConsumerprocesses a received batch by validating the consumer epoch per message. IfredeliverUnacknowledgedMessages()runs concurrently, it can incrementconsumerEpochwhile the batch loop is still iterating, which can produce a mixed outcome where part of the batch is accepted and the rest is filtered. This matches the behavior reported in #25204.Modifications
incomingQueueLockacross the entire batch loop and theincomingMessages.size()read, soconsumerEpochcannot change mid-batch.MultiTopicsConsumerEpochRaceTestto assert the post-fix invariant:acceptedByEpochCount == 2)Verifying this change
flaky, so it must not be excluded):mvn --% -pl pulsar-client "-Dtest=org.apache.pulsar.client.impl.MultiTopicsConsumerEpochRaceTest" "-DexcludedGroups=quarantine" testmvn -pl pulsar-client testDoes this pull request potentially affect one of the following parts
The threading modelDocumentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: ChimdumebiNebolisa#2