[ISSUE #10572] Add dual TTL policy for tiered storage read-ahead cache#10573
Open
Houlong66 wants to merge 1 commit into
Open
[ISSUE #10572] Add dual TTL policy for tiered storage read-ahead cache#10573Houlong66 wants to merge 1 commit into
Houlong66 wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #10573 +/- ##
=============================================
- Coverage 49.01% 48.16% -0.85%
+ Complexity 13485 13418 -67
=============================================
Files 1376 1378 +2
Lines 100527 100864 +337
Branches 12983 13047 +64
=============================================
- Hits 49274 48584 -690
- Misses 45251 46317 +1066
+ Partials 6002 5963 -39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RockteMQ-AI
reviewed
Jul 11, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Introduces a dual-TTL policy for the tiered storage read-ahead cache: unread entries use a longer createTtl (default 180s), then after first read switch to a shorter afterReadTtl (default 10s). Falls back to legacy single-TTL expireAfterAccess when both dual TTLs are disabled.
Findings
- [Info]
MessageStoreFetcherImpl.java— TheDualTtlExpiryimplementing Caffeine'sExpiryinterface is clean and correct.expireAfterCreate/expireAfterUpdatereturncreateNanos,expireAfterReadreturnsafterReadNanos— this gives the intended "long before read, short after read" semantics. - [Info]
resolveReadAheadCacheTtl()has solid fallback logic: both disabled → legacy; one disabled → usereadAheadCacheExpireDurationas fallback for the missing one; both partially invalid → legacy. Well-covered by tests. - [Info]
TieredMessageStore.createFetcher()is extracted as aprotectedmethod to allow subclass override. The Javadoc correctly warns about virtual dispatch from constructor — good defensive documentation. - [Info]
memoryMaxSizechanged fromprivatetoprotected— necessary for the subclass override pattern. Acceptable. - [Warning]
DualTtlExpiry.expireAfterUpdateresets tocreateNanoson update. This means if a cache entry is re-put (same key), it gets the full create TTL again. The testdualTtlCache_readThenRePutResetsToCreateTtlconfirms this is intentional. Just flagging this as a behavioral note: repeated writes to the same offset will keep entries alive at the longer TTL. - [Info] The warning log when
afterReadTtl >= createTtlis a nice touch — helps operators catch misconfiguration. - [Info] Test coverage is comprehensive: default config, disabled dual TTL, partial fallback, invalid partial fallback, create-TTL expiry, after-read-TTL expiry, re-put reset, and the
isAfterReadNotShorteredge case. TheFakeTickerapproach is clean.
Suggestions
- The README table still shows the old
readAheadCacheExpireDurationdescription as "Read-ahead cache expiration time". Consider updating it to clarify it's now the legacy fallback, alongside the two new columns.
Automated review by github-manager-bot
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.
Which Issue(s) This PR Fixes
Brief Description
This PR adds a native dual-TTL policy for the tiered storage read-ahead cache.
The new default behavior keeps unread prefetched entries for
180000msafter creation, then switches entries to a shorter10000msTTL after they are read. This gives consumers more time to consume read-ahead batches while allowing already-read entries to be released sooner.Main changes:
readAheadCacheCreateExpireDurationandreadAheadCacheAfterReadExpireDurationtoMessageStoreConfig.readAheadCacheExpireDurationas the legacy single-TTL fallback.Expiryfor create/read/update-specific expiration.How Did You Test This Change?