[fix][client] Fix multi-topics consumer could receive old messages after seek#21945
Merged
Technoboy- merged 4 commits intoapache:masterfrom Jan 30, 2024
Conversation
Contributor
Author
|
This issue should also exist for other |
1e7fa57 to
47237a5
Compare
47237a5 to
2b2a6a8
Compare
BewareMyPower
added a commit
to BewareMyPower/pulsar-client-cpp
that referenced
this pull request
Jan 24, 2024
### Motivation See apache/pulsar#21945 ### Modifications In C++ client, the multi-topics consumer receives messages by configuring internal consumers with a message listener that adds messages to `incomingMessages_`. So this patch pauses the listeners before seek and resumes them after seek. Add `MultiTopicsConsumerTest.testSeekToNewerPosition` for test.
Technoboy-
approved these changes
Jan 24, 2024
RobertIndie
reviewed
Jan 29, 2024
Member
RobertIndie
left a comment
There was a problem hiding this comment.
Good work! Left one comment.
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java
Outdated
Show resolved
Hide resolved
Contributor
Author
|
@codelipenghui I have addressed your comments, PTAL again. |
codelipenghui
approved these changes
Jan 30, 2024
RobertIndie
approved these changes
Jan 30, 2024
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21945 +/- ##
============================================
+ Coverage 73.59% 73.67% +0.07%
- Complexity 32417 32489 +72
============================================
Files 1861 1863 +2
Lines 138678 138784 +106
Branches 15188 15207 +19
============================================
+ Hits 102060 102245 +185
+ Misses 28715 28651 -64
+ Partials 7903 7888 -15
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Technoboy-
pushed a commit
that referenced
this pull request
Jan 31, 2024
BewareMyPower
added a commit
to apache/pulsar-client-cpp
that referenced
this pull request
Feb 2, 2024
### Motivation See apache/pulsar#21945 ### Modifications In C++ client, the multi-topics consumer receives messages by configuring internal consumers with a message listener that adds messages to `incomingMessages_`. So this patch pauses the listeners before seek and resumes them after seek. Add `MultiTopicsConsumerTest.testSeekToNewerPosition` for test.
Technoboy-
pushed a commit
that referenced
this pull request
Feb 5, 2024
Technoboy-
pushed a commit
that referenced
this pull request
Feb 20, 2024
mukesh-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Mar 1, 2024
…ter seek (apache#21945) (cherry picked from commit dc1b107)
mukesh-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Mar 6, 2024
…ter seek (apache#21945) (cherry picked from commit dc1b107)
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.
Motivation
The multi-topics consumer supports seeking all internal consumers when accepting a timestamp as the argument. However, the multi-topics consumer could still read from earliest after seeking to a specific position. There are two reasons:
incomingMessagesis not cleared beforeseek(long timestamp)seekAsyncwas called and thenincomingMessageswas clearedincomingMessagesincomingMessagesseekAsynccompleted,Consumer#receivewill poll the messages fetched beforeseekcompletedModifications
Add a
duringSeekflag that is set with true when the seek operation starts. Then do not handle messages viamessageReceiveand stopreceiveMessageFromConsumerifduringSeekis true. After the seek option finishes, setduringSeekback tofalseand restartreceiveMessageFromConsumerfor all consumers again.Add
testSeekToNewerPositionto verifyreceive,receiveAsyncand message listener all work for seeking by timestamp to a newer position on a multi-topics consumer.Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: