Repository navigation
fix(cache): invalidate MultiTier L1 on deleteByPrefix/clear, race-safe (#1989) - #2064
Merged
Merged
Conversation
#1989) Closes the L1 stale-read gap: deleteByPrefix/clear only pattern-deleted the L3 backend, but get() reads L1 first, so deleted entries were served from the in-memory tier until TTL. Incorporates both review findings on the original fix: - Race: invalidate L1 BOTH before and after the awaited L3 delete. The before-wipe makes concurrent reads miss L1 fast; the after-wipe drops any entry a racing get() backfilled from a not-yet-deleted L3 value (which would otherwise survive until TTL — the very bug being fixed). - No-delByPattern branch: wipe L1 before the early return so a backend lacking delByPattern still gets its L1 invalidated (was previously skipped). Adds MemoryTier.deleteByPrefix and 4 tests incl. a deferred-gated race test and a no-delByPattern L1-wipe test. Red-green verified per finding. Refs #1989
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.
Supersedes #2050 (rebased onto current main after #2049 merged, with both review findings incorporated).
What
MultiTierCacheRepository.deleteByPrefix/clearonly pattern-deleted the L3 backend, butget()reads L1 first — so deleted entries were served stale from the in-memory L1 tier until TTL.Both #2050 review findings incorporated
get()backfilled from a not-yet-deleted L3 value (which would otherwise survive to TTL — the exact bug).delByPatternbranch: wipe L1 before the early return, so a backend lackingdelByPatternstill gets L1 invalidated (previously skipped).Adds
MemoryTier.deleteByPrefixand 4 tests including a deferred-gated race test and a no-delByPattern L1-wipe test. Red-green verified: each finding's test fails on the corresponding broken variant and passes with the fix.Refs #1989