Repository navigation
fix(layers/foyer): skip cached entries for conditional reads - #8451
Open
Mola-maker wants to merge 1 commit into
Open
Mola-maker wants to merge 1 commit into
Mola-maker wants to merge 1 commit into
Conversation
A cached full-object entry carries no precondition, so serving it to a conditional read would never validate the condition against the origin. On a cache hit, fall back to the origin, which observes the original read args. On a cache miss the fill below still validates the condition at the origin, preserving the args-preserving fill from apache#7718. This addresses the remaining part of apache#7686: the fill path was fixed by apache#7718, but the hit path still ignored preconditions.
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.
A cached full-object entry carries no precondition, so serving it to a conditional read would never validate the condition against the origin: after a fill, a later read with a different if-match (or any other precondition) would return the cached bytes with Ok even when the live object no longer satisfies it.
This change makes a conditional read fall back to the origin when an entry for its key is already cached. On a cache miss the fill path is unchanged: it still validates the condition at the origin while filling, as fixed by #7718.
versionkeeps using the cache because it is part of the cache key.Tests:
test_conditional_read_bypasses_full_object_cache: fills the cache with an unconditional read, then asserts a conditional read contacts the origin again and that later unconditional reads still hit the cache. It failed before the fix (origin open calls stayed at 1) and passes after.cargo test -p opendal-layer-foyer: 10 lib tests + 2 doc tests pass.cargo test -p opendal-core --lib: 236 passed.cargo clippy -p opendal-layer-foyer --all-targets -- -D warningsandcargo fmt --all -- --checkclean.Fixes #7686.
AI Usage: Harness: Muse; Model: Muse Spark; Effort: investigation and tests.