[fix][broker] Fix NonDurable Subscription msgBackLog incorrect after topic unload#23305
Open
summeriiii wants to merge 3 commits intoapache:masterfrom
Open
[fix][broker] Fix NonDurable Subscription msgBackLog incorrect after topic unload#23305summeriiii wants to merge 3 commits intoapache:masterfrom
summeriiii wants to merge 3 commits intoapache:masterfrom
Conversation
Contributor
Author
Technoboy-
reviewed
Sep 19, 2024
pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java
Outdated
Show resolved
Hide resolved
691386d to
80c923e
Compare
Contributor
|
re-run the failed test |
Technoboy-
reviewed
Sep 25, 2024
| if (ledgerId >= 0 && entryId >= 0 | ||
| && msgId instanceof BatchMessageIdImpl) { | ||
| && msgId instanceof BatchMessageIdImpl | ||
| && (msgId.getBatchIndex() >= 0 || resetIncludeHead)) { |
Contributor
There was a problem hiding this comment.
Adding resetIncludeHead should start a PIP. right now, we can only fix by adding msgId.getBatchIndex() >= 0
Contributor
Author
There was a problem hiding this comment.
But if we just add the msgId.getBatchIndex() >= 0, test of method ReaderBuilder#startMessageIdInclusive will fail
Contributor
Author
There was a problem hiding this comment.
I will draft a pip to fix this issue later
80c923e to
54b4feb
Compare
54b4feb to
e3bfce6
Compare
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 #23239
Motivation
Briefly describe the issue:
Consumer consumed all messages and then the msgBacklog is 0, but after topic unload, the msgBacklog turned to be 1 instead of 0 which is not what we expected. The detail is in test NonDurableSubscriptionTest#testNonDurableSubscriptionBackLogAfterTopicUnload.
Root cause:
I analysed the related code, and found this issue was introduced by #4331. In the #4331,
if (((BatchMessageIdImpl) msgId).getBatchIndex() >= 0) {was deleted directly, which cause none batch message will also execute the stepentryId = msgId.getEntryId() - 1;. Because of this, the entryId reduced by 1, then the msgBacklog turned to be 1 instead of 0.In the #4331, we added
ReaderBuilder#startMessageIdInclusiveinterface to allow create Reader which read containes startMessageId, but it has not been implemented correctly. We should add the field resetIncludeHead in CommandSubscribe to implement it.Modifications
(msgId.getBatchIndex() >= 0 || resetIncludeHead), entryId -1 will execute Only when msg is batch or the resetIncludeHead is true.Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: