vfs/disk: Fix EvictDiskVisibilityAndRecreateSafety flake #19

Merged
Ghost merged 2 commits from fix/disk-evict-stat-race into develop 2026-09-01 15:21:06 -05:00

What

Make insertBatch fail-closed: re-stat under lock and skip gone files so bg population cannot resurrect keys after Evict/Delete. Tighten EvictDiskVisibility test (drain init via Size) and add InsertBatchSkipsGoneFiles. Optional: paths-ignore markdown on push to main.

Why

CI #1145 failed under -race -shuffle=on: Stat succeeded while the backing file was already gone. Create does not wait on initDone; the bg scan can discover files that eviction later removes, then insertBatch re-indexed the stale discovery.

Test

  • go test -race -count=20 -shuffle=on ./vfs/disk green locally
  • No LICENSE change

Fixes #18

## What Make `insertBatch` fail-closed: re-stat under lock and skip gone files so bg population cannot resurrect keys after Evict/Delete. Tighten EvictDiskVisibility test (drain init via Size) and add InsertBatchSkipsGoneFiles. Optional: paths-ignore markdown on push to main. ## Why CI #1145 failed under `-race -shuffle=on`: Stat succeeded while the backing file was already gone. Create does not wait on initDone; the bg scan can discover files that eviction later removes, then insertBatch re-indexed the stale discovery. ## Test - `go test -race -count=20 -shuffle=on ./vfs/disk` green locally - No LICENSE change Fixes #18
Ghost added 2 commits 2026-09-01 15:19:59 -05:00
New() launches background calculateSizeAndPopulateIndex which scans
disk and calls insertBatch. Create does not wait on initDone, so a
file can be written and indexed, discovered by the scan, then removed
from d.info and disk by EvictLRU/EvictBySize. insertBatch then
re-inserted the stale discoveredFile without checking the path still
existed, so Stat succeeded from the index while os.Stat failed.

Re-stat under the lock and skip gone files so evicted keys are not
resurrected.

Fixes #18.
ci: Skip test workflow on markdown-only pushes
CI / vulncheck (pull_request) Successful in 14s
CI / check-and-test (pull_request) Successful in 40s
acd006d4a2
Docs-only pushes to main (**.md / CONTRIBUTING.md) do not need the
full check-and-test job. Pull requests are unchanged.
Ghost merged commit 5d006ac44f into develop 2026-09-01 15:21:06 -05:00
Ghost deleted branch fix/disk-evict-stat-race 2026-09-01 15:21:06 -05:00
Sign in to join this conversation.