[improve][storage] Periodically rollover Cursor ledgers #22622
Merged
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
Each ManagedCursor stores its own status on a BookKeeper ledger and this ledger is rolled over when one of these conditions are met: some time passed or too many entries have been written.
The problem is that the condition is checked only while writing to the ledger: if no consumer sends acknowledgments then the ledger is never rolled over.
This may become a problem because there will be a long lived ledger that doesn't respect the configuration set by the administrator for "ledger rollover".
Creating a new ledger allows the Bookies to reclaim space, especially thanks to the GC (Garbage collection) mechanism, and then with the Compaction.
Having a long lived ledger prevents the Bookie to release disk space promplty with the GC, and so only Compaction can release space, but compaction is an expensive operation.
For this reason in some usecases you want to configure a frequent rollover of the ledgers for the topics, and thus you want that such rollover happens at the same frequency also for the cursor ledgers.
Modifications
This patch simply allows the broker to periodically check every ManagedCursor and apply the rollover configuration even when there is no consumer activity.
Verifying this change
This change added tests
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: eolivelli#26