Skip to content

fix(layers/foyer): skip cached entries for conditional reads - #8451

Open
Mola-maker wants to merge 1 commit into
apache:mainfrom
Mola-maker:fix/7686-foyer-read-args
Open

Mola-maker wants to merge 1 commit into
apache:mainfrom
Mola-maker:fix/7686-foyer-read-args

Conversation

@Mola-maker

Copy link
Copy Markdown
Contributor

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. version keeps using the cache because it is part of the cache key.

Tests:

  • New test 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 warnings and cargo fmt --all -- --check clean.

Fixes #7686.

AI Usage: Harness: Muse; Model: Muse Spark; Effort: investigation and tests.

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.
@Mola-maker
Mola-maker requested a review from Xuanwo as a code owner November 1, 2026 04:17
@github-actions github-actions Bot added core releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:M This PR changes 30-99 lines, ignoring generated files. labels Nov 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: FoyerLayer ignores read args while filling full-object cache

1 participant