Repository navigation
[improve][broker] Reduce cache retention after reads and apply retention settings at startup - #26627
Merged
Merged
Conversation
merlimat
approved these changes
Sep 17, 2026
4 of 11 tasks
dao-jun
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Sep 20, 2026
…ion settings at startup (apache#26627) (cherry picked from commit bed06a0)
dao-jun
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Sep 20, 2026
…ion settings at startup (apache#26627) (cherry picked from commit bed06a0)
dao-jun
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Sep 20, 2026
…ion settings at startup (apache#26627) (cherry picked from commit bed06a0)
dao-jun
added a commit
to ascentstream/pulsar
that referenced
this pull request
Sep 21, 2026
Brings in the base's cursor reset/GC series (checkpoint ledger sweep, batch-index-ack dirty flagging, failed-flush GC race hardening) and the persistentUnackedRangesMaxEntrySize startup validation. The only textual conflict was the add/add on ManagedLedgerClientFactoryTest — resolved by keeping both sides' tests (apache#26627's cache-extension settings plumbing tests plus the base's checkpoint maxEntrySize validation tests). ManagedCursorTest 214/214 and the merged factory test 6/6 green on the merged tree.
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
Recently accessed managed-ledger cache entries currently receive an extra TTL extension by default, even after their expected reads have completed. For consumers keeping up with a topic, this retains already-read entries longer and increases cache occupancy without necessarily serving additional reads.
Disable this recent-access extension by default to reduce that retention. Expected-read retention remains enabled, with up to five TTL extensions for entries with remaining expected reads.
A comparison with 500 producers on separate connections and 20 consumers on one Key_Shared subscription showed the following results. Both configurations used the same broker code, one persistent topic, random keys, unbatched 128-byte messages, unrestricted production with at most 40 outstanding sends per producer, and a 12-million-message receive target. Only the recent-access extension setting differed.
true)false), two runsSteady throughput uses topic counters after 20 seconds of warmup, includes only intervals with all 500 producers connected, and ends before producers disconnect. Cache size is the cache's accounting of stored data, not total heap usage. Allocation reductions were not consistent. These short runs demonstrate the benefit for this workload; they do not establish the same improvement for multiple subscriptions or lagging consumers.
The broker also accepts two cache retention settings without passing them to the managed-ledger factory during initialization. Dynamic update listeners do not apply initial values, so startup configuration can silently leave the factory's defaults in effect. Correct startup propagation is necessary for the new broker default and for explicit operator settings to take effect.
Modifications
managedLedgerCacheEvictionExtendTTLOfRecentlyAccessedtofalseinServiceConfiguration,broker.conf, andstandalone.conf, and update their configuration documentation.managedLedgerCacheEvictionExtendTTLOfRecentlyAccessedandmanagedLedgerCacheEvictionExtendTTLOfEntriesWithRemainingExpectedReadsMaxTimestoManagedLedgerFactoryConfigduring initialization.Deployments that benefit from retaining recently read entries, such as repeated reads across subscriptions or redelivery, can explicitly set
managedLedgerCacheEvictionExtendTTLOfRecentlyAccessed=trueto retain the previous policy. Existing configuration files that explicitly settruecontinue to do so.Verifying this change
Parameterized tests capture the factory configuration during initialization and verify the new broker default, explicit enable/disable overrides, and expected-read extension limits. The startup propagation regression test fails without the factory assignments.
./gradlew :pulsar-broker:test --tests '*ManagedLedgerClientFactoryTest' -PtestRetryCount=0./gradlew spotlessCheck checkstyleMain checkstyleTestDoes this pull request potentially affect one of the following parts:
Broker startup honors both retention settings, and recent-access TTL extension is disabled by default.