[do not merge] [branch-2.9] just reproduce issue: ledgers lost #18661
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
In PR #17526, we know that a
topic
can be closed multiple times and that it is possible to have two same-named objects of classPersistenttopic
in the samebroker
instance.We know that closing the
topic
triggers the closure of theManagedLedger
. Thetopic
object can be closed multiple times which means theManagedLedger
can be closed multiple times. This PR is used to prove: If aManagedLedger
is closed more than once, and switchedledgerHandle
operation ofManagedLedger
and method closed executed concurrently, there will be two of the same-namedManagedledger
in the same broker, possibly with different numbers of cursors.If both Managedledgers are available and there are different numbers of cursors, this can cause the operation
trimLedgers
to delete too many ledgers from the meta ofManagedLedger
.Here is the process:
managedLedger_1.close
switch ledgerHandle(managedLedger_1)
create managedLedger_2
create managedLedger_3
LedgerHandle
LedgerHandle
Closed
managedLedger_1
fromManagedFactory.ledgers
LedgerHandle
LedgerOpened
managedLedger_2
managedLedger_2
toManagedFactory.ledgers
managedLedger_2
fromManagedFactory.ledgers
cursor_1
intomanagedLedger_2
managedLedger_3
managedLedger_3
toManagedFactory.ledgers
cursor_1
from metacursor_2
intomanagedLedger_3
cursor_1
cursor_1
,cursor_2
How to reproduce
Run the test
LedgerLostTest.testConcurrentCloseLedgerAndSwitchLedger
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: