Repository navigation
fix: update entries already admitted to LRU2Cache - #16503
Open
zsewasdsdsd wants to merge 1 commit into
Open
zsewasdsdsd wants to merge 1 commit into
zsewasdsdsd wants to merge 1 commit into
Conversation
Preserve the two-write admission policy for new keys, but update values already present in the main cache. Keep the existing lock and access-ordered eviction behavior. Add regressions for promoted-entry updates, previous values, LRU eviction order, and null-valued entries. Fixes apache#16500
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16503 +/- ##
============================================
- Coverage 60.92% 58.96% -1.97%
Complexity 15 15
============================================
Files 1953 1953
Lines 89278 89280 +2
Branches 13476 13476
============================================
- Hits 54390 52641 -1749
- Misses 29313 30945 +1632
- Partials 5575 5694 +119
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Summary
Fixes #16500.
This PR fixes an issue in
LRU2Cache.put()where updating a key that has already been promoted to the main cache does not replace its existing value.Problem
LRU2Cacheuses a two-write admission policy:put()records the key in the history cache (preCache).put()promotes the key into the main cache.put()calls should update the existing cached value.However, the current implementation only checks whether the key exists in
preCache. Once a key has been promoted, it is removed frompreCache, causing subsequent updates to be treated as new entries instead of updating the main cache.As a result, callers may continue receiving stale cached values.
Changes
Verification
RED — Before the fix
GREEN — After the fix
LRU2CacheTestusing Maven on Windows with Java 21.No full-repository test suite or distributed RPC integration tests were run.
Impact
This change ensures that already-admitted cache entries can be updated correctly without changing the admission policy for new keys or introducing new dependencies.