fix(managed-ledger): handle stale backlog after trimmed ledgers#26094
Open
ShuKe-code wants to merge 1 commit into
Open
fix(managed-ledger): handle stale backlog after trimmed ledgers#26094ShuKe-code wants to merge 1 commit into
ShuKe-code wants to merge 1 commit into
Conversation
Treat synthetic earliest positions as fully consumed when historical ledgers have been trimmed and only an empty current ledger remains. Add a regression test covering earliest cursor recreation after retention trim so approximate and precise backlog both stay at zero.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
When an inactive durable subscription is deleted and later recreated(or first creation) with
SubscriptionInitialPosition.Earliest, backlog can be reported incorrectly if historical ledgers have already been trimmed and only an empty current ledger remains.In this case,
getFirstPositionAndCounter()may derive the initial counter from a synthetic earliest position that points to a trimmed ledger range. As a result:Changes
ManagedLedgerImpl#getFirstPositionAndCounter()lastConfirmedEntryandentriesAddedCounterwhen historical ledgers are already trimmed and only an empty current ledger remainsResult
After the fix, recreating a durable subscription with
Earliestin this scenario no longer reports stale backlog. Approximate backlog and precise backlog remain consistent.Testing
ManagedLedgerTest#testEarliestCursorAfterTrimmedLedgersUsesCurrentEntriesAddedCounterissues
#25813