Repository navigation
refactor(relay): stop creating three tables nothing writes - #25354
Conversation
relay_confirmable_splices, relay_cell_drain_attempts and relay_migration_leases are created at every boot and referenced nowhere else on main except tests. In production all three hold 0 rows and pg_stat_user_tables shows 0 inserts, 0 sequential and 0 index scans since the 2026-09-28 stats reset. This removes them from the schema and the transaction-phase table, and drops the test references. It does not drop them: an older image still runs CREATE TABLE IF NOT EXISTS at boot, and a drop racing that create can fail the older boot's schema step. A follow-up can drop them once no image that creates them can be rolled back to.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Drops three never-written tables from
SCHEMA—relay_confirmable_splices,relay_cell_drain_attempts, andrelay_migration_leasesare no longer created at boot on either the SQLite or Postgres path. - Removes their two
POSTGRES_TRANSACTION_PHASESentries — error-phase attribution only; therelay_cell_drain_prefix still covers the live drain tables. - Updates tests — the SQLite table-list assertion and the
relay_migration_leasescleanupDELETEare pruned. - Adds
dead-relay-tables-postgres.test.ts— a fresh database has none of the three, and a database with them still boots and leaves them in place.
Verified independently: a repo-wide grep finds no non-test reference to any of the three names (migration_leases elsewhere is the relay_assignments column; relay_cell_drain_attempt_states is a distinct live table). relayPostgresSchemaStatements() and POSTGRES_SCHEMA_MIGRATIONS contain none of them, the lock-target golden list holds only indexes/columns/constraints, and nothing pins POSTGRES_TRANSACTION_PHASES. Both new test cases are falsifiable, and the deferral of DROP TABLE is documented and correctly reasoned.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe relay schema no longer creates Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No actionable issue is established for this schema change. It appears mergeable after the reported database and PostgreSQL checks are confirmed. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The change stops creating three unused tables without deleting existing tables or changing live drain and migration storage. No new production entrypoint, privilege, or materially weakened security control was identified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |

ELI5
The relay creates three database tables at every boot that nothing has ever written to or read from. This stops creating them. It does not delete them yet, because an older relay version that is still running, or that we roll back to, would re-create them and could trip over a concurrent delete.
What Changed
SCHEMAno longer createsrelay_confirmable_splices,relay_cell_drain_attemptsorrelay_migration_leases.relay_cell_drain_still covers the live drain tables.DELETEinpostgres-drain-send-locking.test.ts.SCHEMArecords why existing databases keep the empty tables.Nothing changes at runtime. New databases simply do not get the three tables.
Why
Zero non-test references on
main.git grepacross the repo finds them only indatabase.ts(the CREATEs and phase entries) and the two test files above.relay_cell_drain_attemptsis distinct from the liverelay_cell_drain_attempt_states.relay_migration_leasesis distinct from the liverelay_assignments.migration_leasescolumn.Zero rows and zero use in production (read-only session, 2026-10-04/05):
count(*)= 0 for all three.pg_stat_user_tablesshowsn_tup_ins = 0,seq_scan = 0andidx_scan = 0since the 2026-09-28 stats reset.Why not
DROP TABLEnow. Cells and directors on older images still runCREATE TABLE IF NOT EXISTSfor these at boot. During a mixed-version rollout, or a rollback, aDROPon one instance can race:pg_typeunique violation.Either fails that boot's schema step. The tables cost nothing while empty. A follow-up can add
DROP TABLE IF EXISTSonce no image that creates them can be rolled back to.Linked Issue
N/A. Relay redesign step 0 (internal).
Visual Proof
N/A. Schema code only; there is no UI or client-visible change.
Testing
dead-relay-tables-postgres.test.ts(local Postgres 16, port 55440):database.test.ts,relay-schema-lock-targets.test.ts(golden list unchanged;CREATE TABLEtakes no relation lock) andrelay-schema-catalog-precheck-postgres.test.tspass.cloud/apps/relay:pnpm typecheckpasses, and the full relay suite with Postgres passes.Review
Notes