[fix][ml] fix potential data lose when enable lazy cursor recovery #20814
[fix][ml] fix potential data lose when enable lazy cursor recovery #20814lifepuzzlefun wants to merge 2 commits into
Conversation
2. add programmed readEntry delay in `PulsarMockLedgerHandle`
|
@lifepuzzlefun Please add the following content to your PR description and select a checkbox: |
|
@poorbarcode @mattisonchao Could you take a look this pr ? |
| static final AtomicLongFieldUpdater<ManagedLedgerImpl> LAZY_RECOVERY_IN_PROCESS = AtomicLongFieldUpdater | ||
| .newUpdater(ManagedLedgerImpl.class, "lazyRecoveryInProcess"); | ||
| @SuppressWarnings("unused") | ||
| private volatile long lazyRecoveryInProcess = 0; |
There was a problem hiding this comment.
Since the variable uninitializedCursors is tracing the cursor, which is in initialize progress. I think the new variable lazyRecoveryInProcess is not needed.
There was a problem hiding this comment.
Thanks for review, I agree with you. The idea to use this variable here is to avoid get the synchronized lock of the managedledger instance. current uninitializedCursors is not thread safe. so each time a call to get synchronized lock is needed. I submit another to make this map thread safe. #20674. Need some guide to handle this. If acquire synchronized lock is acceptable. I will change the code in this style.
|
The pr had no activity for 30 days, mark with Stale label. |
Motivation
when user enable lazyCursorRecovery.
if one cursor success recovered and ack some message, and the other cursor recovery is delayed for sometime.
if the finished cursor markdeletepos moved it may trigger
internalTrimLedgerand delete ledger only decide by this cursor.so after the other cursor finished recovery, these cursor may occur "data lose" because of the early trim.
Modifications
PulsarMockLedgerHandleVerifying this change
This change added tests and can be verified as follows:
add unit test in ManagedLedgerTest.onlyTrimCursorAfterLazyRecoverFinished
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: