test(stack): use unique table name to avoid transient race condition#488
Conversation
Both packages/protect/__tests__/searchable-json-pg.test.ts and packages/stack/__tests__/searchable-json-pg.test.ts ran beforeAll "CREATE TABLE IF NOT EXISTS protect-ci-jsonb (... IDENTITY)" against the same Postgres service container, and Turbo schedules the two package's test tasks in parallel. CREATE TABLE is not atomic w.r.t. its implicit IDENTITY sequence, so a concurrent run could see "table doesn't exist" but then fail on "sequence protect-ci-jsonb_id_seq already exists". The bumped turbo+vitest in this group shifted timing enough to surface the latent race. Rename stack's table to "protect-ci-jsonb-stack" so the two suites own disjoint relations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR updates the PostgreSQL test suite for encrypted JSON searchability to target a new table ChangesPostgreSQL encrypted test table migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Both
packages/protect/__tests__/searchable-json-pg.test.tsandpackages/stack/__tests__/searchable-json-pg.test.tsranbeforeAll'sCREATE TABLE IF NOT EXISTS "protect-ci-jsonb" (... GENERATED ALWAYS AS IDENTITY)against the same Postgres service container, and Turbo schedules the two packages' test tasks in parallel.PostgreSQL's
CREATE TABLEis not atomic w.r.t. its implicit IDENTITY sequence. Two racing sessions can both see "table doesn't exist", both proceed past theIF NOT EXISTSguard, and one fails onduplicate key value violates unique constraint "pg_class_relname_nsp_index"forprotect-ci-jsonb_id_seq.Seen on https://github.com/cipherstash/stack/actions/runs/26382743607/job/77655050703 — surfaced by the timing shift from the turbo/vitest bumps in #487.
The race has been latent since the stack test was ported (aa5a2d0, March 2026). Rename the stack-side table to
protect-ci-jsonb-stackso the two suites own disjoint relations.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit