-
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][broker] Reader stuck after call hasMessageAvailable when enable replicateSubscriptionState #22572
Conversation
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java
Outdated
Show resolved
Hide resolved
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.
Overall looks good to me, just left some minor comments about the code style
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/TransactionBuffer.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedger.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorSubscriptionTest.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Outdated
Show resolved
Hide resolved
… replicateSubscriptionState
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorSubscriptionTest.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Outdated
Show resolved
Hide resolved
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
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.
|
… replicateSubscriptionState (apache#22572) (cherry picked from commit a761b97)
… replicateSubscriptionState (apache#22572) (cherry picked from commit a761b97)
The PR handled the case of ServerOnlyMarker, but it looks we also need to handle txn aborted messages. |
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/ManagedLedgerImplUtils.java
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/ManagedLedgerImplUtils.java
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/ManagedLedgerImplUtils.java
Show resolved
Hide resolved
… replicateSubscriptionState (apache#22572) (cherry picked from commit a761b97) (cherry picked from commit 1dacca5)
… replicateSubscriptionState (apache#22572) (cherry picked from commit a761b97) (cherry picked from commit 1dacca5)
Motivation
#22571
Analysis
When enabling
replicateSubscriptionState
will use topic to sync subscription state, and make these message metadata as MarkerThese
marker
messages 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
getLastMessageId
will always return the last message position, regardless of whether the last message ismarked
ornot
. This will cause the reader stuck.You can refer to this diagram to help understand this bug:
Modifications
asyncReverseFindPositionOneByOne
method onManagedLedger
.getLastCanDispatchPosition
method onTopic
, it will callasyncReverseFindPositionOneByOne
to find the last position of entry that not isreplistateSubscriptionState
getLastMessageId
implement ofServerCnx
to usegetLastCanDispatchPosition
instead ofgetMaxReadPosition
.Verifying this change
ManagedLedgerTest.testReverseFindPositionOneByOne
to cover ReverseFindPositionOneByOne method.testReplicatedSubscriptionAcrossTwoRegionsGetLastMessage
to cover this bug.Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository