[fix][broker] Reader stuck after call hasMessageAvailable when enable replicateSubscriptionState#22572
Merged
Merged
Conversation
lhotari
reviewed
Apr 24, 2024
dao-jun
reviewed
Apr 24, 2024
dao-jun
approved these changes
Apr 25, 2024
dao-jun
left a comment
Member
There was a problem hiding this comment.
Overall looks good to me, just left some minor comments about the code style
dao-jun
reviewed
Apr 25, 2024
coderzc
reviewed
Apr 28, 2024
… replicateSubscriptionState
codelipenghui
approved these changes
Apr 28, 2024
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #22572 +/- ##
============================================
+ Coverage 73.57% 74.13% +0.56%
+ Complexity 32624 2747 -29877
============================================
Files 1877 1886 +9
Lines 139502 140653 +1151
Branches 15299 15462 +163
============================================
+ Hits 102638 104278 +1640
+ Misses 28908 28331 -577
- Partials 7956 8044 +88
Flags with carried forward coverage won't be shown. Click here to find out more.
|
codelipenghui
pushed a commit
to codelipenghui/incubator-pulsar
that referenced
this pull request
Apr 28, 2024
… replicateSubscriptionState (apache#22572) (cherry picked from commit a761b97)
codelipenghui
pushed a commit
to codelipenghui/incubator-pulsar
that referenced
this pull request
Apr 28, 2024
… replicateSubscriptionState (apache#22572) (cherry picked from commit a761b97)
Member
|
The PR handled the case of ServerOnlyMarker, but it looks we also need to handle txn aborted messages. |
15 tasks
nikhil-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
May 13, 2024
… replicateSubscriptionState (apache#22572) (cherry picked from commit a761b97) (cherry picked from commit 1dacca5)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
May 16, 2024
… replicateSubscriptionState (apache#22572) (cherry picked from commit a761b97) (cherry picked from commit 1dacca5)
hanmz
pushed a commit
to hanmz/pulsar
that referenced
this pull request
Feb 12, 2025
… replicateSubscriptionState (apache#22572)
Demogorgon314
pushed a commit
to Demogorgon314/kop
that referenced
this pull request
Apr 15, 2026
…osition implementation for compaction (streamnative#606) ### Motivation apache/pulsar#22891 introduces some changes for the PositionImpl. Now we need to use the Position interface instead of the PositionImpl. ### Modifications - Refactor to use Position instead of PositionImpl - apache/pulsar#22572 uses `getLastDispatchablePosition` instead of `getMaxPosition` to return the last message id, this patch implements the new method for `KopPersistentTopic`. - apache/pulsar#22838 changed the result for `checkTopicExists`. This PR also adapts to changes. - apache/pulsar#22882 removed the method `org.apache.pulsar.broker.service.Producer.updateRates(int numOfMessages, long msgSizeInBytes)`. We need to use `producer.getStats().recordMsgIn` instead. --------- Co-authored-by: Yunze Xu <xyzinfernity@163.com>
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
#22571
Analysis
When enabling
replicateSubscriptionStatewill use topic to sync subscription state, and make these message metadata as MarkerThese
markermessages will not be sent to the consumer by the topic, and will automatically ack them.pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
Lines 202 to 217 in fc393f6
But
getLastMessageIdwill always return the last message position, regardless of whether the last message ismarkedornot. This will cause the reader stuck.You can refer to this diagram to help understand this bug:
Modifications
asyncReverseFindPositionOneByOnemethod onManagedLedger.getLastCanDispatchPositionmethod onTopic, it will callasyncReverseFindPositionOneByOneto find the last position of entry that not isreplistateSubscriptionStategetLastMessageIdimplement ofServerCnxto usegetLastCanDispatchPositioninstead ofgetMaxReadPosition.Verifying this change
ManagedLedgerTest.testReverseFindPositionOneByOneto cover ReverseFindPositionOneByOne method.testReplicatedSubscriptionAcrossTwoRegionsGetLastMessageto cover this bug.Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository