mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
63eb43d50a
Every existing Postgres integration test runs strictly one transaction at a time, so none of them exercise the SERIALIZABLE retry-and-fence path CreateProposal actually depends on for correctness under real matcher-replica contention -- only concurrent goroutines against a real connection can. Add a test that races two goroutines each proposing a formation that shares one contested ticket (a realistic scenario: nothing stops two matcher replicas reading the same QUEUED ticket in the same poll window), and asserts exactly one proposal commits, the loser's proposal and participant rows are fully rolled back, the contested ticket ends up claimed by the winner, and -- the part a single-threaded test can't show -- the loser's OWN uncontested ticket also rolls back to QUEUED rather than being left stranded as PROPOSED with no surviving proposal. Adversarial review of my own first draft: it initially failed deterministically (5/5 runs), but the failure was in the test itself -- the winner/loser branch picking the loser's uncontested ticket had the two branches swapped, so it was checking the WINNER's ticket against the QUEUED expectation. Fixed and re-verified clean across 8 runs with -race, plus the full integration suite.