test(server): Postgres concurrency harness — make the write races observable (CWD-11) - #323
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every server test runs on PGlite, whose
Mutexserializes all store calls — no existing test can observe a lost update. The write races the Concurrency & Write Durability epic (OB-76) fixes only manifest on real Postgres (MVCC + pool), so the epic needed a harness that makes them reproducible before any fix can be proven. Board: CWD-11.Solution
A dedicated real-Postgres suite (
*.pg.ts, own vitest config, excluded from the default runner both directions) with: barrier/start-gate interleaving primitives (participant-keyed rendezvous with deadline — a hung barrier or dead server surfaces as a loud harness fault, never as a false "race reproduced"); threetest.failsbaseline races documenting today's live bugs (updateRow blob clobber, instance-config lost key, setPageProperties interleaving — each tagged with the CWD issue that flips it); scratch-DB-per-test provisioning with fault-tolerant teardown; a runner preflight that proves the target is a real Postgres with CREATE DATABASE rights (born of a week-long hunt for a stale process squatting the harness port); and a PR-gating CI job with a Postgres service container.Key files:
packages/server/src/postgresConcurrency.pg.ts,src/testUtils/concurrency.ts,scripts/test-pg.mjs,docker-compose.test-pg.yml,.github/workflows/ci.yml. New deps: none.Before / After
No visual change — test infrastructure.
3 expected faildocuments each live racetest.fails→test(flip obligations documented at each site)Postgres concurrency (write races)job, service container, ~2s suiteTest procedure
Operational notes
Postgres concurrency (write races)to branch protection's required contexts — auto-merge fires on fast checks, so an unrequired job can be bypassed.pnpm verifyis untouched (PGlite-only); the pg suite runs only with the env var.Verify: green (full
pnpm verify; one unrelated backupBoot flake ruled out by isolated rerun — tracked as INF-3). Real-Postgres leg: 3 passed | 3 expected fail, exit 0, adversarially probed (hung-barrier, dead-port, and mid-run-kill scenarios all fail loud). Reviews cleared: code (Quinn — 2 rounds incl. empirical mutation/flip probes; final endorsement on the F6/F7 diff).🤖 Generated with Claude Code
https://claude.ai/code/session_018RUicirLRuuZvjJN13N6yN