vfs/cache: Fix data race between memoryWriteCloser.Close and promoteToFast #22

Closed
opened 2026-09-01 15:25:05 -05:00 by Ghost · 2 comments

Goal

Unred main tip CI. Push run https://git.s1d3sw1ped.com/s1d3sw1ped/steamcache2/actions/runs/1152 failed on tip a2ac13d317d6 (post #20). vfs/disk is green; this is a separate race in vfs/cache.

Failure

Job check-and-test under go test -race -shuffle=on:

WARNING: DATA RACE
Write at ... by goroutine N:
  steamcache2/vfs/memory.(*memoryWriteCloser).Close()
      vfs/memory/memory.go:178
  steamcache2/vfs/cache.TestTieredCache_Concurrent.func1()
      vfs/cache/cache_test.go:117

Previous read at ... by goroutine M:
  steamcache2/vfs/cache.(*TieredCache).promoteToFast()
      vfs/cache/cache.go:194
  steamcache2/vfs/cache.(*TieredCache).Open.gowrap1()
      vfs/cache/cache.go:85

--- FAIL: TestTieredCache_Concurrent
--- FAIL: TestTieredCache_PromotionFallback
FAIL steamcache2/vfs/cache

Shuffle seed from the failing run: 1788294214215599121. Both tests were CONT at once (t.Parallel); PromotionFallback may be collateral from the package race detector, but the Close vs promoteToFast race is real.

Do

  1. Fix the race so promoteToFast / Open does not read memory being Closed (or serialize the Close path). Prefer a production fix over silencing the test.
  2. Prove locally: go test -race -count=20 -shuffle=on ./vfs/cache
  3. PR to develop, then land on main. Do not merge yourself. Style: /home/box/forge/git-style.md (area: Imperative summary).
  4. Do not cite leftover ansible issues with #N in the PR body.

Out of scope

  • Lab SSH / ansible
  • Ignoring the race (-race off, skipping the tests)
  • Re-opening the closed disk flake work (#18)

Revert

git revert the fix commit.

## Goal Unred `main` tip CI. Push run https://git.s1d3sw1ped.com/s1d3sw1ped/steamcache2/actions/runs/1152 failed on tip `a2ac13d317d6` (post #20). `vfs/disk` is green; this is a separate race in `vfs/cache`. ## Failure Job `check-and-test` under `go test -race -shuffle=on`: ``` WARNING: DATA RACE Write at ... by goroutine N: steamcache2/vfs/memory.(*memoryWriteCloser).Close() vfs/memory/memory.go:178 steamcache2/vfs/cache.TestTieredCache_Concurrent.func1() vfs/cache/cache_test.go:117 Previous read at ... by goroutine M: steamcache2/vfs/cache.(*TieredCache).promoteToFast() vfs/cache/cache.go:194 steamcache2/vfs/cache.(*TieredCache).Open.gowrap1() vfs/cache/cache.go:85 --- FAIL: TestTieredCache_Concurrent --- FAIL: TestTieredCache_PromotionFallback FAIL steamcache2/vfs/cache ``` Shuffle seed from the failing run: `1788294214215599121`. Both tests were CONT at once (`t.Parallel`); PromotionFallback may be collateral from the package race detector, but the Close vs promoteToFast race is real. ## Do 1. Fix the race so `promoteToFast` / Open does not read memory being Closed (or serialize the Close path). Prefer a production fix over silencing the test. 2. Prove locally: `go test -race -count=20 -shuffle=on ./vfs/cache` 3. PR to `develop`, then land on `main`. Do not merge yourself. Style: `/home/box/forge/git-style.md` (`area: Imperative summary`). 4. Do not cite leftover ansible issues with `#N` in the PR body. ## Out of scope - Lab SSH / ansible - Ignoring the race (`-race` off, skipping the tests) - Re-opening the closed disk flake work (https://git.s1d3sw1ped.com/s1d3sw1ped/steamcache2/issues/18) ## Revert `git revert` the fix commit.

Next action: Ash owns one PR (develop → then main). Main tip is red on this race (CI run 1152). Leave ansible leftovers alone. Do not merge yourself.

Next action: Ash owns one PR (develop → then main). Main tip is red on this race (CI run 1152). Leave ansible leftovers alone. Do not merge yourself.

Duplicate of #21 (opened first for the same CI 1152 race). Closing this one.

Duplicate of https://git.s1d3sw1ped.com/s1d3sw1ped/steamcache2/issues/21 (opened first for the same CI 1152 race). Closing this one.
Ghost closed this issue 2026-09-01 15:25:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: s1d3sw1ped/steamcache2#22