Skip to content

[Bug]: S3 full-object disk-cache fills synchronously expose fsync tail latency to SQL #27366

Closed

Description

@XuPeng-SH

Branch Name

main

Commit ID

c6b2ac9

Other Environment Information

  • MatrixOne source image built from current main
  • Linux amd64, Docker deployment with 2 CN + TN + LogService + Proxy + MinIO
  • One CN's disk-cache path was mounted on a loopback FUSE filesystem that delays every real file fsync by 21 seconds; a second CN used the normal ext4 path as the control
  • Test table: 100,000 rows, 204,800,000 payload bytes, low-compressibility SHA-256 data

Actual Behavior

S3 full-object cache fills call DiskCache.SetFile synchronously. SetFile copies the object to a temporary file and then waits for f.Sync, close, rename, and cache-index publication before the foreground S3FS.Read returns. This path does not honor S3FS.asyncUpdate, even though disk cache is an optional acceleration layer.

With the same empty-cache aggregate scan on both CNs:

  • Normal CN: 10.799 seconds.
  • CN with 21-second disk-cache fsync: 43.348 seconds.
  • The delayed query returned the correct 100000 / 5000050000 / 204800000 / 51032400 aggregates, but started five delayed cache fsync calls and took 32.549 seconds longer (4.0x total latency).
  • Every injected fsync completed in 21.0-21.96 seconds. Neither CN restarted or OOMed.

The synchronous boundary exists in both buffered and streaming full-object read paths. S3 writes that populate full-file disk cache also call SetFile synchronously.

Expected Behavior

When asynchronous cache updates are enabled, the foreground storage operation may synchronously consume source data needed by the caller, but optional disk-cache durability/publication work (fsync, close, rename, and index update) must not add disk tail latency to SQL/S3 completion.

The implementation should have bounded ownership and shutdown semantics: transfer the open temporary file and per-path update ownership to a bounded cache worker, keep the final path invisible until rename succeeds, clean temporary files and release path ownership on failure/close, and retain a synchronous mode for callers that explicitly disable asynchronous updates.

Steps to Reproduce

  1. Deploy MatrixOne with 2 CN + MinIO and enable disk cache.
  2. Create a low-compressibility table large enough to force full-object cache fills.
  3. Start one CN with an empty disk cache on a filesystem where each file fsync takes at least 21 seconds; leave the second CN unchanged with an empty cache.
  4. Directly run the same full-table aggregate scan against each CN.
  5. Observe that the delayed CN's foreground SQL waits for disk-cache fsync, while the control CN completes after object read/compute.

Additional information

  • S3FS.readFullObjectToDiskCacheStreaming calls diskCache.SetFile inline and returns only after it finishes.
  • The buffered full-object read path and S3 write cache-population path also call SetFile inline.
  • DiskCache.writeFile performs f.Sync, f.Close, os.Rename, and cache-index publication before returning.
  • Consequences under degraded local disks include query/write timeouts, blocked I/O-merge waiters, connection and goroutine buildup, retries that amplify object-store load, and a local cache failure cascading into CN-level tail-latency or availability incidents.

Activity

  1. added
    kind/bug
    on Aug 20, 2026
  2. added
    severity/s0
    and removed on Aug 20, 2026
  3. added a commit that references this issue on Aug 21, 2026
    70cd802
  4. added 3 commits that reference this issue on Sep 17, 2026
    2f7ae34
    61f94b0
    1c17af6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions