A Go test that passed 40,000 times, then lost a write under load
Say a client writes a value and gets a success back. Later, the value is gone. It happens once in production, around the time a node restarts, and every test is green. A week later a CI job fails on a test nobody touched. The re-run passes, so someone adds a retry and moves on. Bugs like this need a rare timing, such as a partition during a leader election, or a crash after a write was…
A Go test failed after 40,000 successful runs when a write was lost under load, due to a nondeterministic select statement. The test passed 40,000 times on an idle machine, but failed 23 times out of 60,000 runs when the CPU was heavily loaded. The failure was non-deterministic and impossible to reproduce with normal tests, as they don't control the clock, goroutine scheduling, network, or disk.
A deterministic simulation testing approach could have identified the issue by controlling all sources of nondeterminism, running the test in a simulated environment with controlled conditions, and re-running failing seeds to verify fixes.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to