Skip to content

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

@Xuanwo

Description

@Xuanwo

Describe the bug

FoyerLayer can ignore OpRead / OpStat arguments while filling the full-object cache.

In core/layers/foyer/src/full.rs, FullReader::fallback_open and fallback_read correctly call the inner accessor with self.args.clone(). However, read_full_object() fills the cache by calling:

  • stat(&path_clone, OpStat::default())
  • read(&path_clone, OpRead::default())

The cache key only includes path and version, derived from self.args.version().

This can make the cache-fill path observe different read conditions than the original reader request.

Steps to Reproduce

  1. Enable FoyerLayer.
  2. Read an object through reader_with(path) or read_with(path) with read arguments such as version, if_match, if_none_match, or other conditional read options.
  3. Trigger a full-object cache miss so read_full_object() fills the cache.
  4. Observe that the cache-fill path uses default read/stat args instead of the original request args.

Relevant code:

  • fallback_open uses self.args.clone(): core/layers/foyer/src/full.rs
  • fallback_read uses self.args.clone(): core/layers/foyer/src/full.rs
  • cache-fill uses OpStat::default() and OpRead::default(): core/layers/foyer/src/full.rs
  • cache key only includes path and version: core/layers/foyer/src/full.rs

Expected Behavior

The cache-fill path should preserve the semantics of the original read request.

At minimum:

  • stat / read used for cache fill should be derived from self.args.
  • Versioned reads should not accidentally fetch latest content and store it under a versioned cache key.
  • Conditional reads such as if_match / if_none_match should either be respected during cache fill or explicitly bypass the cache after validating the condition.

Additional Context

This was found during post-merge review of the read-reader refactor. The new design makes Access::read return a reusable raw reader, so layers need to preserve OpRead semantics across both reader creation and later reader-side IO.

Suggested tests:

  • FoyerLayer + reader_with(path).version(v) cache miss/hit behavior.
  • FoyerLayer + read_with(path).if_match(...) cache miss/hit behavior.
  • Ensure fallback and cache-fill paths observe the same read arguments.

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions