Repository navigation
[fix] [ml] incorrect non-durable cursor's backlog due to concurrently trimming ledger and non-durable cursor creation - #23951
Conversation
…y trimming legder and non-durable cursor creation
|
/pulsarbot rerun-failure-checks |
Could you explain which method does it happen? From the table in the PR description, I can only see:
but I'm not sure where does 6 happen. |
It is in the method |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #23951 +/- ##
============================================
+ Coverage 73.57% 74.23% +0.65%
+ Complexity 32624 32280 -344
============================================
Files 1877 1853 -24
Lines 139502 143849 +4347
Branches 15299 16355 +1056
============================================
+ Hits 102638 106782 +4144
+ Misses 28908 28671 -237
- Partials 7956 8396 +440
Flags with carried forward coverage won't be shown. Click here to find out more.
|
BewareMyPower
left a comment
There was a problem hiding this comment.
Synchronizing the creation of NonDurableCursorImpl does not fix the race condition you mentioned. From your table in the PR description.
- 1 happens in
ManagedLedgerImpl#initializeCursorPosition, which is called inNonDurableCursorImpl's constructor - 2, 3, 4, 5 happen in
ManagedLedgerImpl#internalTrimLedgers - 6 happens in
ManagedCursorImpl#setAcknowledgedPosition, which is called inasyncMarkDeleteorasyncDelete.
The change in this PR just synchronizes NonDurableCursorImpl's construction and internalTrimLedgers. The order 1 -> 2 -> 3 -> 4 -> 5 -> 6 could still be possible after that.
…l/ManagedLedgerImpl.java Co-authored-by: Yunze Xu <[email protected]>
… trimming ledger and non-durable cursor creation (#23951) Co-authored-by: Yunze Xu <[email protected]> (cherry picked from commit cc7b381)
… trimming ledger and non-durable cursor creation (#23951) Co-authored-by: Yunze Xu <[email protected]> (cherry picked from commit cc7b381)
… trimming ledger and non-durable cursor creation (#23951) Co-authored-by: Yunze Xu <[email protected]> (cherry picked from commit cc7b381)
… trimming ledger and non-durable cursor creation (apache#23951) Co-authored-by: Yunze Xu <[email protected]> (cherry picked from commit cc7b381)
… trimming ledger and non-durable cursor creation (apache#23951) Co-authored-by: Yunze Xu <[email protected]>
… trimming ledger and non-durable cursor creation (apache#23951) Co-authored-by: Yunze Xu <[email protected]> (cherry picked from commit cc7b381) (cherry picked from commit 16bfb1a)
… trimming ledger and non-durable cursor creation (apache#23951) Co-authored-by: Yunze Xu <[email protected]> (cherry picked from commit cc7b381) (cherry picked from commit 05797ac)
… trimming ledger and non-durable cursor creation (apache#23951) Co-authored-by: Yunze Xu <[email protected]> (cherry picked from commit cc7b381) (cherry picked from commit 16bfb1a)
Motivation
Background: the logic of calculating
backlogmanegedledger.entriesAddedCounter, which means how many entries were added after the topic was loaded up at the latest time.cursor.messagesConsumedCounter, which means how many entries were acked after the cursor was loaded up at the latest time, it can be a negative value.manegedledger.entriesAddedCounter - cursor.messagesConsumedCounterSteps to reproduce the issue
ledgers: [ 1, 2, 3 ],100entries per ledger.durable-cursor: {mark-deleted-position: 3:0}manegedledger.entriesAddedCounter:0, no entries were added after the topic was loaded up.trim ledgersmessagesConsumedCounterbymanagedLegder.ledgers:-300cursorsaddCursorsAfter that, if the non-durable cursor receives messages
3:0~3:99and acknowledges them, themessagesConsumedCounterwill be -200 (-300 + 100). Then backlog will be 200, but there is no message to consume|The issue we encountered
Modifications
ml.synchronized, add a lock when creating a non-durable cursorDocumentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: x