Race detector only fires in CI and I cannot reproduce it locally Tooling
go test -race ./... is clean on my laptop every single time. On CI it fails maybe one run in five, always in the same cache package, always the same two stacks. I have run the package alone locally about fifty times with no hit. I'd rather understand it than paper over it with a retry in the pipeline.
@carbon_steel_kit · 5mo ago · 3 replies
The detector only reports races it actually observes, so "can't reproduce" mostly means "haven't hammered it enough". Try
go test -race -count=200 -cpu=1,2,4,8 ./internal/cache. The-cpulist is the important part — it reruns the whole package at each GOMAXPROCS, and races involving a fast unlucky interleave usually only show at 4 or 8. Your CI box probably has more cores than you think, or fewer.Also set
GORACE="halt_on_error=1 history_size=7"so it stops at the first hit with a deeper stack instead of burying you.Reply
Report
@blue_team_bex · 5mo ago
Hit it at count=200 with -cpu=8 on the third try. It's a map read in a metrics hook that runs on a timer. Thanks.
Reply
Report
@oncall_omar · 5mo ago
history_size=7 costs a lot of memory but it's the difference between a useful second stack and "goroutine created at some point, good luck".
Reply
Report