-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][ml]Received more than once callback when calling cursor.delete #24405
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][ml]Received more than once callback when calling cursor.delete #24405
Conversation
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Outdated
Show resolved
Hide resolved
|
@poorbarcode Could you please write down the reason that why the callback get called multiple times? If there is anything that we cannot control (network failures or something). I'm good to add a defensive solution to avoid multiple calls. If the issue which we can control, I would like to fix the issue at the first place. |
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24405 +/- ##
============================================
+ Coverage 73.57% 74.26% +0.69%
+ Complexity 32624 32313 -311
============================================
Files 1877 1868 -9
Lines 139502 145366 +5864
Branches 15299 16629 +1330
============================================
+ Hits 102638 107958 +5320
+ Misses 28908 28860 -48
- Partials 7956 8548 +592
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…pache#24405) (cherry picked from commit 72953bf)
…pache#24405) (cherry picked from commit 72953bf) (cherry picked from commit b3c9cdf)
…pache#24405) (cherry picked from commit 72953bf) (cherry picked from commit 2d9ac9b)
…pache#24405) (cherry picked from commit 72953bf) (cherry picked from commit 2d9ac9b)
…pache#24405) (cherry picked from commit 72953bf) (cherry picked from commit b3c9cdf)
Motivation
About cursor deleting, there are two cases
scenario-A: Acked nothing, because all positions have been acknowledged before.scenario-B: Acked some position, then it will try tomark-deleted.scenario-B1: Acked some positions, butindividualDeletedMessagesbecame empty after combining ranges in the methodsetAcknowledgedPosition,scenario-B2: Acked some positions, andindividualDeletedMessageswas still not empty.Triggering callbacks
scenario-A, Cursor will skip callingmark-deleted, because it is meaningless.scenario-B, Cursor will callmark-deleted, which will trigger acallback.Issue
Regarding the
scenario-B1, the Cursor triggers twice the callbacks.individualDeletedMessagesis empty. https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L2479mark-deleted. https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L2499Modifications
To confirm the scenario matches
scenario-A, rather than confirmingindividualDeletedMessages.isEmpty, use a specific variable to record it.Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: x