Skip to content

[Bug]: SetAsyncUpdate(true) does not make disk-cache updates asynchronous #27359

Closed

Description

@XuPeng-SH

Branch Name

main

Commit ID

6f42b19

Other Environment Information

  • MatrixOne source build / matrixorigin/matrixone:local
  • Linux amd64, Docker multi-CN test deployment

Actual Behavior

CachingFileService.SetAsyncUpdate(true) is documented as setting cache updates to asynchronous mode, and LocalFS/S3FS pass their asyncUpdate flag into DiskCache.Update. However, DiskCache.Update never uses the async argument. It enters writeFile, whose startUpdateWithCleanup waits on an existing update for the same cache path. Therefore an async=true update still blocks its caller behind a slow or stuck disk-cache update.

A white-box reproduction ran 3 times. With an existing update held for the same IOEntry path, DiskCache.Update(..., async=true) remained blocked for at least 150 ms and returned only after the held update was released.

Expected Behavior

When asynchronous update is enabled, the caller should not synchronously wait for disk-cache I/O or an in-progress update. The implementation should enqueue or otherwise schedule the update with explicit ownership/lifetime handling for the vector data, and define close/error/cancellation behavior. async=false may retain synchronous behavior.

Steps to Reproduce

  1. In package pkg/fileservice, create a DiskCache.
  2. Hold cache.startUpdate(cache.pathForIOEntry("foo", IOEntry{Offset: 0, Size: 1})).
  3. Start cache.Update(ctx, &IOVector{FilePath: "foo", Entries: []IOEntry{{Offset: 0, Size: 1, Data: []byte("x")}}}, true) in a goroutine.
  4. Observe that it remains blocked until the held update is released.
  5. Diagnostic command:
    GOWORK=off go test -mod=readonly -v -count=3 ./pkg/fileservice -run TestCodexDiskCacheAsyncFlagStillWaits

Additional information

  • The public interface comment is in pkg/fileservice/caching_file_service.go: SetAsyncUpdate sets cache update operation to async mode.
  • LocalFS and S3FS default asyncUpdate to true and pass it to their disk-cache update calls.
  • pkg/fileservice/disk_cache.go accepts the flag but does not branch on it; startUpdateWithCleanup waits in a condition-variable loop.
  • Under disk-cache p99 latency or a stalled filesystem, this can turn a cache optimization into synchronous request blocking and contribute to tail-latency and waiter buildup.

Activity

  1. added
    kind/bug
    on Aug 19, 2026
  2. XuPeng-SH commented on Aug 19, 2026

    @XuPeng-SH
    ContributorAuthor

    High-depth cause analysis:\n\nThe public SetAsyncUpdate contract is not connected to an asynchronous execution boundary for DiskCache. LocalFS and S3FS default asyncUpdate to true and pass it into DiskCache.Update from deferred Read cleanup, but DiskCache.Update never branches on async. It enters writeFile directly, then performs same-path exclusion, file copy, f.Sync, rename, and cache index updates on the caller stack.\n\nThis creates two effects: the advertised async mode adds the complete disk write latency to Read completion, and a canceled Read can continue synchronous cache work after its request is no longer useful. The missing queue or worker ownership model also means there is no defined bound for pending async work, no data-lifetime transfer, and no close/error completion contract. The deterministic white-box wait reproduction proves the flag is not merely an implementation detail: async=true and the existing-update wait have the same synchronous behavior.

  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/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions