Repository navigation
Drop the unused delivery_log and subscriptions tables - #9772
TheSentinel454 wants to merge 7 commits into
Conversation
🔐 Codex Security Review
Review SummaryOverall Risk: NONE
FindingsNo concrete security, correctness, or reliability findings were identified. Notes
Generated by Codex Security Review | |
joahg
left a comment
There was a problem hiding this comment.
🤖 Checked at this head: nothing outside migration 0105 and the dropped-table tests still reads or writes delivery_log, subscriptions or the three enums. Crates, migrations, schema, scripts, docs and ARCHITECTURE are clean, there is no .sqlx metadata, and the only remaining mentions are the deliberate DROPPED_SCOPED_TABLES approval-compat list and tests. The drops are CASCADE-free, so an unexpected dependent fails the migration, and the tables were never written by a release, so having no down migration is fine. CI is green, including the PostgreSQL, relay e2e and populated-upgrade tests. Two notes: #9746 is merged but must be deployed everywhere before 0105 runs, as the PR says, and open #9794 also adds a 0105_* migration (main is at 0104), so whichever merges second needs to renumber to 0106.
wpfleger96
left a comment
There was a problem hiding this comment.
🤖 Automated review at c462097b: changes requested for one documentation gap. The migration and code look right.
The migration, the deletion catalog change and the handling of approvals made before the drop all hold up. A live run on a throwaway Postgres confirmed it. Migrations through 0104 plus 0105 apply with empty and populated tables, and a rerun succeeds. An unexpected view or column on the dropped tables or types makes 0105 fail with 2BP01 and keeps everything. A held lock ends the attempt with 55P03 in about 0.35s, and a retry succeeds. pgschema plan after 0105 matches the base.
Blocking: the chart's upgrade docs don't name the new required stop. docs/database.md Rule 5 says the release notes must name the release to stop at before a contract migration. deploy/charts/buzz/README.md "Upgrades" is where the earlier stops live ("Required stop before migrations 0089–0091, 0095 and 0096", "Required stop before migration 0100"). It also says that outside those, helm upgrade is the entire upgrade procedure. 0105 needs #9746 deployed first, but neither PR adds that stop there.
This matters for Helm users because no tagged relay release contains #9746 yet. The latest is relay-v0.3.0, so the next tag would ship #9746 and 0105 together, and a deployment on 0.3.0 has nothing to stop at. relay-v0.3.0 still boots after 0105, since its serving check needs only communities, community_serving_write_leases and community_deletion_requests. But on it, community deletion fails its exact catalog check, because delivery_log and subscriptions are in its EXPECTED_SCOPED_TABLES. User deletion's account batches still query the dropped tables, and startup partition maintenance logs "Failed to ensure partitions". That happens on old pods during a rolling upgrade, and indefinitely after a rollback to 0.3.0. No data is lost, but deletions fail.
Suggested fix: add a "Required stop before migration 0105" paragraph to the chart README, modelled on the 0100 entry. It should name the stop build (sha-7e94503 or later, or the first tagged relay release containing #9746). It should say that a rollback after 0105 must target that build or later, with migrate.autoMigrate=false. And it should say what an older build loses.
Non-blocking: migration_0105_drops_populated_delivery_tables (crates/buzz-db/src/runtime/migration.rs:4348) checks both tables but only delivery_method of the three dropped types. Adding to_regtype('subscription_status') and to_regtype('pause_reason') would cover the rest.
|
🤖 @wpfleger96 Fixed in b89256be90d0cd0619effe3c3bf7fad11d232323: the chart README now has a "Required stop before migration 0105" paragraph. It names |
Migration 0105 drops both tables and the three enums only they used. manifest, pgschema ignore list and reconcile script drop their delivery_log parts. Community deletion's catalog is an exact set again. A frozen approval from before 0105 may still list the two tables, and validate_approved_schema accepts that they are gone. Signed-off-by: Luke Tornquist <tornquist@squareup.com> Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pgschema drops the fence function before the tables whose triggers still use it. A deployment applies 0105 first, so the fixture does too. Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
- Restore the executor check that an approval frozen with the dropped tables still reaches RetentionPending on its original digest. - Test that 0105 drops populated tables, and state the discard decision. - Apply 0105 before pgschema in start-relay-for-tests.sh. - docs: run the rollback build with auto-migration off after the drop. Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Also check all three dropped types in the populated 0105 test. Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Main took 0105 for the push gateway in-flight column (#9802). The drop moves to 0106. Every reference, the count test and the chart README required stop now name 0106. Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
b89256b to
bbaaaf3
Compare
wpfleger96
left a comment
There was a problem hiding this comment.
🤖 No blocking issues at bbaaaf3d. The upgrade notes now name the required stop at #9746, which was the one blocker last time, and the drop is correctly renumbered to 0106 after main took 0105.
- Upgrade path, run for real: a relay built from the base migrated a fresh database through
0105, then took one row in each ofdelivery_logandsubscriptions. The relay built from this head then applied0106on startup. Both tables, all sixdelivery_logpartitions and the three enums are gone,0105's checksum is unchanged, and the relay served/_readiness,/healthand NIP-11. - Renumber: no stale
0105reference to the drop remains in code, tests, docs, scripts or the description. Main's0105only adds a column topush_gateway_delivery_request_replays, so it doesn't depend on the dropped objects, andscripts/start-relay-for-tests.shstill drops the tables before pgschema runs. - Stop and rollback:
7e94503fis #9746's merge commit, and the rollback steps match the neighboring0100entry.
Two minor wording points in the new README paragraph are inline.
Say that the failures on older builds lose no data, but 0106 discards any rows left in the tables. Scope the user-deletion failure to builds after relay-v0.3.0, which has no user-deletion executor. Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
wpfleger96
left a comment
There was a problem hiding this comment.
🤖 Automated review of 852660cd. Clear.
The one new commit rewords the 0106 required-stop paragraph in deploy/charts/buzz/README.md and resolves both wording notes from the last review:
- It now says the failures on older builds lose no data and, separately, that 0106 discards any rows left in the tables, with a prompt to export them first.
- User-deletion failure is scoped to builds after
relay-v0.3.0. That matches the source:relay-v0.3.0has only the user-deletion preparation modules, and the executors (#9363, #9364, #9365, #9580) landed between that tag and7e94503f.relay-v0.3.0is still covered by "builds before commit7e94503f".
The rest of the branch is unchanged from bbaaaf3d, which was reviewed and run through the populated upgrade earlier. CI is green on this head.
Summary
Contract step after #9746. Migration
0106dropsdelivery_log,subscriptions, and the three enums only they used (delivery_method,subscription_status,pause_reason). The tables were created for a delivery feature that was never built. No code uses them since #9746, and no foreign key touches them since0102–0104.Required stop: #9746 must be deployed everywhere before this migration runs. An older relay or deletion executor still selects from these tables.
Changes
migrations/0106_drop_delivery_tables.sql:DROP TABLE IF EXISTSandDROP TYPE IF EXISTS, with the same lock budgets as0102–0104. NoCASCADE, so an unexpected dependent fails the migration.schema/: removes the two tables, thedelivery_logpartitions, and the three types..pgschemaignoreandscripts/reconcile-schema-after-pgschema.sqldrop theirdelivery_logparts.scripts/drop-partitioned-foreign-keys.sqltouchesdelivery_logonly when it still exists (reused test databases).crates/buzz-db/src/store/deletion.rs):delivery_logorsubscriptionsis an unknown tenant table and blocks deletion.RETIRING_SCOPED_TABLESbecomesDROPPED_SCOPED_TABLES. Its only use isvalidate_approved_schema, so a request approved before0106still executes after it.docs/database.md"Retiring a tenant-owned table" now describes the two-release process.ARCHITECTURE.mddrops the table row.scripts/cutover/1321_backfill_default_community.sqlis unchanged. It builds its own copy of0001, so its targets still exist in that flow.What got simpler
Testing
embedded_migrator_contains_consolidated_initial_schemachecks0106's statements.dropped_scoped_tables_are_rejected_as_unknown_when_live.approved_schema_tolerates_only_dropped_tables_vanishingcovers a pre-0106approval.The operator database ownership script that checks for
delivery_logas an anchor gets a matching change outside this repo. That change is safe to land first.🤖 Generated with Claude Code