3 ms·
Have you tried running your tests with the race detector enabled? https://go.dev/doc/articles/race_detector https://go.dev/doc/articles/race_detector https://g
by noisem4ker 3y ago
Have you tried running your tests with the race detector enabled?
https://go.dev/doc/articles/race_detector https://go.dev/doc/articles/race_detector
https://go.dev/blog/race-detector https://go.dev/blog/race-detector
It only logs when a race condition happens, and it may have a non-negligible impact on performance, but it should print useful info to aid in debugging.
- imiric 3y agoOh, of course, I always run with -race enabled. But this is what I mean, the races are only detected in CI, not locally. Sometimes the stack traces point to a simple fix in the test itself, but often the issue is much more difficult to troubleshoot, especially since it can't be reproduced locally. It's also frustrating since this behavior is intermittent, and most of the time tests run fine in CI, but there are "troublesome" days when the issues happen much more frequently, which is why I think this is so dependent on the CI infrastructure (GitHub Actions FWIW). A solution would be to run CI on self-managed nodes that behave more reliably, but that has maintenance costs that we don't want to deal with.
- noisem4ker 3y agoI see. My experience with detecting and fixing races using that tool, evidently applied to much simpler code, was basically getting notified that some variable was being written without synchronization by multiple goroutines, protecting it with a mutex, and being good to go. That's why I assumed linearity between running it and coming to a solution.