-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][client] Fix wrong results of hasMessageAvailable and readNext after seeking by timestamp #22363
Merged
BewareMyPower
merged 3 commits into
apache:master
from
BewareMyPower:bewaremypower/fix-seek-ts-latest
Mar 27, 2024
Merged
[fix][client] Fix wrong results of hasMessageAvailable and readNext after seeking by timestamp #22363
BewareMyPower
merged 3 commits into
apache:master
from
BewareMyPower:bewaremypower/fix-seek-ts-latest
Mar 27, 2024
Conversation
This file contains 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
…fter seeking by timestamp ### Motivation After seeking by timestamp, `hasMessageAvailable()` and `readNext()` could return wrong values. The 1st bug was a regression introduced by apache#22201, which modifies `startMessageId` to `seekMessageId` before a seek operation is done. However, the previous behavior is also a bug but accidentally works in this case. When seeking by timestamp, the `seekMessageId` is modified to `earliest`, which should not be compared with `lastMessageIdInBroker` because the actual start position is determined by the seek timestamp, not the `earliest` message id. The 2nd bug was caused by apache#9652, when `startMessageIdInclusive()` is configured to create a reader, it could seek to the position of the latest message when `lastDequeuedMessageId` is `earliest` and `startMessageId` is `latest`. ### Modifications Add a boolean flag `hasSoughtByTimestamp` to represent whether the last seek call accepts a timestamp. If it's true, don't take `startMessageId` into comparison with `lastMessageIdInBroker`, just compare the mark-delete position and last position in the GetLastMessageId response. Add `testHasMessageAvailableAfterSeekTimestamp` to verify the change. For the `readNext` call, if the reader has sought by timestamp, don't seek to the latest position in `hasMessageAvailable`. Modify `testReadMessageWithBatchingWithMessageInclusive` to verify the fix. However, this patch does not modify the existing behavior when `seek` is not called because the inclusive reader relies on the implicit seek operation in `hasMessageAvailable`.
BewareMyPower
requested review from
lhotari,
Technoboy-,
codelipenghui,
RobertIndie,
dao-jun,
poorbarcode and
shibd
March 26, 2024 14:14
lhotari
reviewed
Mar 26, 2024
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ReaderTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Lari Hotari <[email protected]>
lhotari
approved these changes
Mar 26, 2024
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.
LGTM
dao-jun
approved these changes
Mar 27, 2024
shibd
approved these changes
Mar 27, 2024
BewareMyPower
added a commit
to BewareMyPower/pulsar-client-cpp
that referenced
this pull request
Mar 27, 2024
…y timestamp Fixes apache#420 It's a catch-up for apache/pulsar#22363
lhotari
pushed a commit
that referenced
this pull request
Mar 27, 2024
…fter seeking by timestamp (#22363) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 149deaa)
lhotari
pushed a commit
that referenced
this pull request
Mar 27, 2024
…fter seeking by timestamp (#22363) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 149deaa)
BewareMyPower
added a commit
to apache/pulsar-client-cpp
that referenced
this pull request
Mar 28, 2024
…y timestamp (#422) Fixes #420 It's a catch-up for apache/pulsar#22363
BewareMyPower
added a commit
to apache/pulsar-client-cpp
that referenced
this pull request
Mar 28, 2024
…y timestamp (#422) Fixes #420 It's a catch-up for apache/pulsar#22363 (cherry picked from commit 27d8cc0)
Technoboy-
pushed a commit
to Technoboy-/pulsar
that referenced
this pull request
Apr 1, 2024
…fter seeking by timestamp (apache#22363) Co-authored-by: Lari Hotari <[email protected]>
mukesh-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Apr 15, 2024
…fter seeking by timestamp (apache#22363) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 149deaa) (cherry picked from commit 1045f8b)
mukesh-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Apr 17, 2024
…fter seeking by timestamp (apache#22363) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 149deaa) (cherry picked from commit 1045f8b)
mukesh-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Apr 17, 2024
…fter seeking by timestamp (apache#22363) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 149deaa) (cherry picked from commit 1045f8b)
mukesh-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Apr 19, 2024
…fter seeking by timestamp (apache#22363) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 149deaa) (cherry picked from commit 1045f8b)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Apr 23, 2024
…fter seeking by timestamp (apache#22363) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 149deaa) (cherry picked from commit 1045f8b)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/client
cherry-picked/branch-3.0
cherry-picked/branch-3.2
doc-not-needed
Your PR changes do not impact docs
ready-to-test
release/3.0.4
release/3.1.4
release/3.2.2
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
After seeking by timestamp,
hasMessageAvailable()
andreadNext()
could return wrong values.The 1st bug was a regression introduced by
#22201, which modifies
startMessageId
toseekMessageId
before a seek operation is done. However, the previous behavior is also a bug but accidentally works in this case. When seeking by timestamp, theseekMessageId
is modified toearliest
, which should not be compared withlastMessageIdInBroker
because the actual start position is determined by the seek timestamp, not theearliest
message id.The 2nd bug was caused by #9652, when
startMessageIdInclusive()
is configured to create a reader, it could seek to the position of the latest message whenlastDequeuedMessageId
isearliest
andstartMessageId
islatest
.Modifications
Add a boolean flag
hasSoughtByTimestamp
to represent whether the last seek call accepts a timestamp. If it's true, don't takestartMessageId
into comparison withlastMessageIdInBroker
, just compare the mark-delete position and last position in the GetLastMessageId response.Add
testHasMessageAvailableAfterSeekTimestamp
to verify the change.For the
readNext
call, if the reader has sought by timestamp, don't seek to the latest position inhasMessageAvailable
. ModifytestReadMessageWithBatchingWithMessageInclusive
to verify the fix. However, this patch does not modify the existing behavior whenseek
is not called because the inclusive reader relies on the implicit seek operation inhasMessageAvailable
.Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: