Repository navigation
[improve][broker] Make entry cache copying dynamically configurable - #27148
Merged
Merged
Conversation
Apply managedLedgerCacheCopyEntries updates to future inserts through one shared volatile policy. Preserve cached entries and mandatory batch-read copying, and cover dynamic override deletion, asynchronous reads, and concurrent cache creation and publication. Extracted from the request-frame memory tracking change for independent review. Assisted-by: Codex
2 of 4 tasks
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
A cached entry can retain a small slice of a much larger inbound direct-memory buffer. The existing
managedLedgerCacheCopyEntriessetting avoids that retention by copying entry payloads, but changing it currently requires restarting the broker and recreating caches. Operators need to enable or disable copying for future cache inserts without restarting the broker or clearing useful cached data.This change is extracted from #27110 and can be reviewed and merged independently of request-frame memory tracking and limiting.
Modifications
This change makes the existing
managedLedgerCacheCopyEntriessetting dynamically configurable. Existing and newly created entry caches read one shared policy when inserting entries, so updates do not require cache recreation. Updates affect future inserts without clearing or recopying existing entries, while BookKeeper batch reads continue to force copying.volatilefactory configuration field and remove per-cache snapshots that can miss or overwrite concurrent updates during cache creation.Validation: full
./gradlew quickCheckand 41 focused managed-ledger and broker tests passed with retries disabled.Does this pull request potentially affect one of the following parts:
managedLedgerCacheCopyEntriesbecomes dynamic; its default remainsfalse.Best practice
Enable
managedLedgerCacheCopyEntrieswhen cached entry slices retain substantially larger inbound buffers, usingpulsar-admin brokers update-dynamic-config --config managedLedgerCacheCopyEntries --value true. This trades payload-copy work for reduced retention of larger source buffers. Existing cached entries keep their original buffers until normal eviction or removal, so enabling copying does not immediately reclaim their memory. Set the value tofalseto stop copying future normal inserts, or delete the dynamic override to restore the broker's startup setting; batch reads still copy entries.