vfs/cache: Fix promoteToFast race with WriteCloser Close #23
Reference in New Issue
Block a user
Delete Branch "vfs/cache-promote-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Stat returns a FileInfo snapshot (MemoryFS and DiskFS). promoteToFast uses that snapshot only for space/ReadAll guards, then creates in the fast tier with len(content) so it never reads a live FileInfo.Size while WriteCloser.Close updates Size.
Why
Main push CI failed with DATA RACE: memoryWriteCloser.Close writing fi.Size vs promoteToFast reading info.Size after Stat returned the live map entry. Same package run also race-failed PromotionFallback.
Test
go test -race -count=20 -shuffle=on ./vfs/cachegreen locally (Concurrent + PromotionFallback). Also held under -count=100.#21