Skip to content

[Bug]: async disk-cache loader can remove a foreground cache directory #27832

Closed

Description

@gouhongshen

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Closed issue #27519 involved the same test but a different failure: its second read raced asynchronous cache publication and observed S3/disk-hit counters 2/0. PR #27520 added an explicit FlushCache before that second read. The current failure occurs on the first read's retained-buffer capacity assertion, before that barrier, and has a different root cause.

Branch Name

main

Commit ID

9745d3c913286b7a6472ad47034239926d16613c

Other Environment Information

- Runner: self-hosted Linux/x86 coverage runner
- Workflow: MatrixOne ALL CI, Matrixone UT Coverage / UT Coverage on Ubuntu/x86
- Workflow run 33227712612 attempt 1, failed job 99034584237
- PR head: 69fddf095ce22010a9cedc4d40c6e15c562c5e44
- Go tests use `-short -tags matrixone_test -covermode=set` with repository-wide coverage instrumentation.

Actual Behavior

TestS3FSFullObjectDiskCacheFillDoesNotRetainWholeObjectBuffer intermittently fails its first-read capacity assertion:

s3_fs_test.go:1185
Error: "1036231" is not less than "65536"

Immediately before the assertion, the disk-cache worker reports:

write disk cache error: open .../002/fullfoo/<temp>.mofscache.tmp: no such file or directory

The failure is caused by a race between asynchronous disk-cache startup loading and a foreground full-object cache fill:

  1. newDiskCacheWithMetricScope(..., asyncLoad=true, ...) starts loadCache in a goroutine and returns immediately.
  2. The foreground full-object fill calls MkdirAll(<cache>/fullfoo) and is about to call CreateTemp.
  3. loadCache concurrently visits <cache>/fullfoo and unconditionally calls os.Remove(path) for non-root directories that appear empty.
  4. CreateTemp then fails because its parent directory was removed. Disk cache correctly fails open, so readFullObjectToDiskCacheStreaming falls back to the regular full-object read.
  5. The regular path returns content[12345:12352], which retains the full 1 MiB backing buffer. The observed capacity 1,036,231 is exactly 1,048,576 - 12,345, matching this fallback path.

The failing PR changes only catalog, frontend snapshot, and SQL compile code. It does not change pkg/fileservice, disk-cache loading, or S3 reads.

Expected Behavior

Startup cache discovery must not remove directories created or used by the current foreground cache generation. A concurrent first read should either publish the streamed cache file or fail open without returning a small logical range backed by the entire object buffer.

Steps to Reproduce

  1. Create an S3FS with disk-backed object storage and an empty disk-cache directory. Disk cache startup loading is asynchronous.
  2. Immediately write a 1 MiB object with cache writes skipped.
  3. Read a seven-byte range while allowing startup loadCache to run concurrently.
  4. If loadCache removes the newly created fullfoo directory between MkdirAll and CreateTemp, observe the cache write warning and cap(vec.Entries[0].Data) == 1,036,231.

The existing coverage test exercises this race under repository-wide parallel instrumentation; deterministic coverage should coordinate the loader and foreground create boundary rather than rely on repetition.

Additional information

Activity

  1. added
    kind/bug
    on Aug 29, 2026
  2. self-assigned this
    on Aug 29, 2026
  3. added
    severity/s0
    ai-easy
    and removed on Aug 29, 2026
  4. gouhongshen commented on Aug 29, 2026

    @gouhongshen
    ContributorAuthor

    PR #27840 is trying to fix this issue.

  5. gouhongshen commented on Aug 29, 2026

    @gouhongshen
    ContributorAuthor

    PR #27840 has merged and is awaiting manual validation. The issue remains open.

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

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions