vfs/cache: Fix TestTieredCache_Concurrent data race with promoteToFast #21

Closed
opened 2026-09-01 15:24:40 -05:00 by Ghost · 1 comment

Problem

main tip a2ac13d317d6 (merge of disk insertBatch fix via #19/#20) fails CI run 1152 under go test -race in vfs/cache.

Disk package is green. This is a separate race.

Failure (CI #1152)

  • TestTieredCache_Concurrent — DATA RACE
  • TestTieredCache_PromotionFallback — race detected (likely cross-talk / same root)

Race report sketch:

  • Write vfs/memory.(*memoryWriteCloser).Close at memory.go:178 from test goroutine cache_test.go:117 (TestTieredCache_Concurrent.func1)
  • Read (*TieredCache).promoteToFast at cache.go:194 from Open background promote (cache.go:85)

So promote reads memory buffer/state while a writer Close mutates it (or the reverse: concurrent Close vs promote copy).

Wanted

  1. Fix the real race in TieredCache promote path (and/or memory WriteCloser lifetime) so Close cannot race promoteToFast.
  2. Keep go test -race green for ./vfs/cache (and full ./...).
  3. Proof: go test -race -count=20 -shuffle=on ./vfs/cache locally green.
  4. PR base develop. Commit style area: Imperative summary. Do not merge yourself.
  5. Do not put #21 in the PR body (Gitea closes issues on any #N in merge text). Link this issue with a full URL if you mention it.

Out of scope

  • disk insertBatch / #18 (already fixed and on main)
  • CI markdown paths-ignore churn unless needed

Revert

Normal git revert of the PR commit(s). No DB.

## Problem `main` tip `a2ac13d317d6` (merge of disk insertBatch fix via #19/#20) fails CI run 1152 under `go test -race` in `vfs/cache`. Disk package is green. This is a separate race. ## Failure (CI #1152) - `TestTieredCache_Concurrent` — DATA RACE - `TestTieredCache_PromotionFallback` — race detected (likely cross-talk / same root) Race report sketch: - **Write** `vfs/memory.(*memoryWriteCloser).Close` at `memory.go:178` from test goroutine `cache_test.go:117` (`TestTieredCache_Concurrent.func1`) - **Read** `(*TieredCache).promoteToFast` at `cache.go:194` from `Open` background promote (`cache.go:85`) So promote reads memory buffer/state while a writer Close mutates it (or the reverse: concurrent Close vs promote copy). ## Wanted 1. Fix the real race in `TieredCache` promote path (and/or memory WriteCloser lifetime) so Close cannot race promoteToFast. 2. Keep `go test -race` green for `./vfs/cache` (and full `./...`). 3. Proof: `go test -race -count=20 -shuffle=on ./vfs/cache` locally green. 4. PR base `develop`. Commit style `area: Imperative summary`. Do **not** merge yourself. 5. Do **not** put `#21` in the PR body (Gitea closes issues on any `#N` in merge text). Link this issue with a full URL if you mention it. ## Out of scope - disk insertBatch / #18 (already fixed and on main) - CI markdown paths-ignore churn unless needed ## Revert Normal `git revert` of the PR commit(s). No DB.

Next action: Ash owns one PR (develop → then main). Main tip red on CI run 1152 (TestTieredCache_Concurrent Close vs promoteToFast race). Prove with go test -race -count=20 -shuffle=on ./vfs/cache. Do not merge yourself.

Next action: Ash owns one PR (develop → then main). Main tip red on CI run 1152 (`TestTieredCache_Concurrent` Close vs `promoteToFast` race). Prove with `go test -race -count=20 -shuffle=on ./vfs/cache`. Do not merge yourself.
Ghost closed this issue 2026-09-01 15:35:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: s1d3sw1ped/steamcache2#21