Repository navigation
fix(cloud): retry the committed-winner collision codes in relay schema startup - #18553
Conversation
…a startup `CREATE TABLE IF NOT EXISTS` only checks the name before the catalog inserts, so the loser of a concurrent CREATE fails in one of two ways depending on timing: on the catalog unique index (23505, which the startup retry already handled) or, when the winner has committed by the time the loser reaches TypeCreate / heap_create_with_catalog, on the name check those routines repeat (42710 duplicate type, 42P07 duplicate relation). The predicate treated the latter as fatal, so a director could fail startup on a table it was about to find present. This is what turned `postgres-schema-concurrency-postgres.test.ts` red on main and on every relay PR (CI's shared runner loses the race more often than a dev box): a throwaway diagnostic run in CI reported 42710 from TypeCreate and 42P07 from heap_create_with_catalog as the only rejection reasons. Treat 42710/42P07 as retryable for `CREATE TABLE IF NOT EXISTS` and 42P07 for `CREATE [UNIQUE] INDEX IF NOT EXISTS`; every other statement shape still fails fast. The concurrency test now runs ten rounds and reports the loser's SQLSTATE instead of a bare boolean.
|
This run was cancelled 🛑 The workflow was cancelled before completion. Please check the link below for details. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughPostgreSQL schema startup now retries Merge Risk: ⚪ Minimal · up to This change prevents relay startup failures when concurrent PostgreSQL schema creation races have already committed the same table or index. The retry behavior is scoped to idempotent DDL and is covered by targeted and concurrency tests, with no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (1 skipped: 1 unsupported.) Full details: Description checkExplanation The description explains the problem, implementation, testing, and production impact. However, it omits several required template sections, including ELI5, a populated Linked Issue, Visual Proof with an explicit N/A justification, the Testing checklist, and the remaining checklist sections. Resolution Complete the required template sections. Add a simple ELI5 summary, populate
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 |
…grade tests Cloud Verify's Secret scan runs gitleaks over --all refs, so the raw-socket upgrade test on fix/relay-upgrade-malformed-uri (#18547) trips every cloud PR's scan until its allowlist reaches main. Land the allowlist here first.
…a startup (stablyai#18553) * fix(cloud): retry the committed-winner collision codes in relay schema startup `CREATE TABLE IF NOT EXISTS` only checks the name before the catalog inserts, so the loser of a concurrent CREATE fails in one of two ways depending on timing: on the catalog unique index (23505, which the startup retry already handled) or, when the winner has committed by the time the loser reaches TypeCreate / heap_create_with_catalog, on the name check those routines repeat (42710 duplicate type, 42P07 duplicate relation). The predicate treated the latter as fatal, so a director could fail startup on a table it was about to find present. This is what turned `postgres-schema-concurrency-postgres.test.ts` red on main and on every relay PR (CI's shared runner loses the race more often than a dev box): a throwaway diagnostic run in CI reported 42710 from TypeCreate and 42P07 from heap_create_with_catalog as the only rejection reasons. Treat 42710/42P07 as retryable for `CREATE TABLE IF NOT EXISTS` and 42P07 for `CREATE [UNIQUE] INDEX IF NOT EXISTS`; every other statement shape still fails fast. The concurrency test now runs ten rounds and reports the loser's SQLSTATE instead of a bare boolean. * chore(cloud): allowlist the RFC 6455 example Sec-WebSocket-Key for upgrade tests Cloud Verify's Secret scan runs gitleaks over --all refs, so the raw-socket upgrade test on fix/relay-upgrade-malformed-uri (stablyai#18547) trips every cloud PR's scan until its allowlist reaches main. Land the allowlist here first.

Why
postgres-schema-concurrency-postgres.test.tsis red onmain(since #18537's run) and on every relay PR (#18547 twice). It is not a flake.CREATE TABLE IF NOT EXISTSonly checks the name before the catalog inserts. The loser of a concurrent CREATE therefore fails in one of two ways depending on timing:23505onpg_type_typname_nsp_index(already retried), orTypeCreate/heap_create_with_catalog, on the repeated name check:42710(duplicate type) /42P07(duplicate relation).The startup retry predicate treated the second shape as fatal, so a director could fail startup on a table it was about to find present. A throwaway diagnostic run in CI (#18552, closed) reported exactly those two codes as the only rejection reasons.
What
postgres-schema-startup.ts:42710/42P07retryable forCREATE TABLE IF NOT EXISTS,42P07forCREATE [UNIQUE] INDEX IF NOT EXISTS. Every other statement shape still fails fast.database-postgres-timeout.test.ts: retry / no-retry cases for each new code × statement shape.postgres-schema-concurrency-postgres.test.ts: ten rounds, and the failure now carries the loser's SQLSTATE instead ofexpected false to be true.Verified
42P07), fixed predicate passes 18/18 runs.tscclean forapps/relay.Production impact: startup only; a director that lost this race would have crashed and been restarted by Cloud Run / the MIG. No wire or data change.
Also carried
cloud/.gitleaks.toml: the RFC 6455 exampleSec-WebSocket-Keyallowlist from #18547. Cloud Verify's Secret scan runs gitleaks over--allrefs, so #18547's test nonce fails every cloud PR's scan until the allowlist is onmain. Landing it here first; #18547 rebases onto it.