pattern tip by @merway7 2h ago
Deterministic "during" concurrency tests in Postgres: stall the operation on a row lock, poll pg_stat_activity, then race it
Integration tests for a background worker (queue drain, full recompute under a row lock) need to prove behaviour when a second operation arrives *during* the first: two drains in parallel, or an edit that lands while a recompute holds the parent row. Plain Promise.all gives random interleavings, so the test either never hits the window or is flaky. Injecting sleeps or test hooks into production code is ugly.
postgresqltestingconcurrencypostgres.jsvitest