Repository navigation
Stop using the unused delivery_log and subscriptions tables - #9746
Conversation
3675ff1 to
5ee49f6
Compare
wpfleger96
left a comment
There was a problem hiding this comment.
🤖 Reviewed at d5837d81. The retirement itself looks right: retiring tables are purged and verified only while they exist, under the schema lock; validate_approved_schema exempts only RETIRING_SCOPED_TABLES from the missing-table check; subscriptions is purged before users; and the partition manager and audit now cover events only. The new guard that blocks profile cleanup on retained subscriptions rows closes the foreign-key failure that dropping those handlers would otherwise cause.
One blocking issue in the new test, inline below.
Minor, outside the diff: the .pgschemaignore header still says the partition manager creates dated delivery_log monthlies. After this PR it only creates events ones; the delivery_log_p2* patterns are still needed for the monthlies created earlier, so the comment could say that until the drop migration removes them.
wpfleger96
left a comment
There was a problem hiding this comment.
🤖 Re-reviewed at d4bbca79. The test fix and the .pgschemaignore header both look right.
One new blocker, from #9740 (drop the remaining relay foreign keys), which merged to main after this branch's base. It drops subscriptions_community_id_owner_pubkey_fkey. This branch still merges onto main without textual conflicts, but on the merged tree:
retiring_scoped_tables_are_purged_and_verified_while_presentlooks up thesubscriptions→usersforeign key withfetch_oneand panics withRowNotFoundat.expect("subscriptions owner foreign key"). A Postgres run of main + #9740 + this PR reproduced it. The fix is to drop the lookup-and-DROP CONSTRAINTstep and insert the straggler rows directly.- The profile-cleanup guard added in
d5837d81exists only because that foreign key would make final user removal fail. With the key gone it no longer prevents anything: it just blocks profile cleanup on rows nothing reads. I'd remove it along withretained_subscription_blocks_until_the_table_is_droppedand thesubscriptionsparagraph indocs/profile-cleanup.md. - The
RETIRING_SCOPED_TABLESdoc comment says purging these tables ahead ofPURGE_SCOPED_TABLES"satisfies the foreign key fromsubscriptionstousers". That key no longer exists, so the comment should be updated.
Please rebase onto main, make those changes, and run the touched Postgres tests on the rebased head. Those tests are #[ignore]d in CI.
brow
left a comment
There was a problem hiding this comment.
🤖 The pre-review recommends landing this after one fix. Since #9740 merged, retiring_scoped_tables_are_purged_and_verified_while_present panics on current main because the subscriptions to users foreign key it looks up no longer exists, so merging this head would break main's PostgreSQL checks. Please update the branch onto main and make the changes Will listed in his review (drop the key lookup in that test, and remove the profile-cleanup guard, its test and doc paragraph, which no longer protect anything); this is approved once that head is verified.
Nothing has ever written to delivery_log or subscriptions; they came with the initial schema for a delivery feature that was never built. Remove every reader, writer, partition-manager entry and deletion selection so a later contract migration can drop both tables. Community deletion lists them as retiring tables: the catalog accepts each one present or absent, the purge deletes its rows only while it exists, and an approval that froze one still runs after the drop. The tables stay in the schema until that migration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
While the retiring subscriptions table exists, its FK to users would fail final identity removal after earlier profile batches commit. Check for owned rows before any mutation and tell the operator how to clear them. The check is skipped once the table is dropped. Also pin two retirement seams with tests: an approval frozen before the drop still completes through the executor, and new events partitions inherit a PUBLIC SELECT grant from the parent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Preview returns an error when prerequisites remain, so the regression test now asserts that error before it checks the printed blocker. Name the PUBLIC grant test cluster_global_ so nextest runs it in the serialized role group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
#9740 dropped the subscriptions foreign keys. Final user removal no longer fails on a retained row, so the profile cleanup guard blocks nothing real. Remove it with its test and doc paragraph. The retiring table test now seeds stragglers without lifting a constraint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
d4bbca7 to
11ac1e8
Compare
|
🤖 Updated onto main (with #9740) at 11ac1e8:
The PostgreSQL lanes are running on the merged tree now. |
🔐 Codex Security Review
Review SummaryOverall Risk: NONE
FindingsNo concrete security, correctness, or reliability findings were identified. Notes
Generated by Codex Security Review | |
wpfleger96
left a comment
There was a problem hiding this comment.
🤖 Re-checked at 11ac1e8d (rebased onto main, which now includes #9740). The retiring-table purge test now seeds its stragglers without the foreign-key lookup, and the profile-cleanup guard, its test and its doc paragraph are gone. CI is green, and main hasn't changed any of this PR's files since its base.
Non-blocking: the RETIRING_SCOPED_TABLES doc comment in crates/buzz-db/src/store/deletion.rs (line 144) still says purging these tables first "satisfies the foreign key from subscriptions to users". #9740 removed that key, so the clause can go, here or in the drop-migration follow-up.
…ead-dot * origin/main: Refine iOS composer and transcribe recordings into drafts (#9574) fix(mobile): recognize agents without NIP-OA in Huddles (#8545) test(relay): cover member-cache invalidation routes and refill orders (#9748) perf(mobile): stop re-scanning the unread backlog on channel list rebuilds (#9780) feat(mobile): restore the iOS share extension in the build (#9783) fix(mobile): send Siri Bestie messages without confirmations (#9779) feat(mobile): add Dart notification body formatter (#9556) fix(mobile): hand message action menu scrolling off to sheet dismissal (#9760) feat(cli): add many channel members per kind:9000 event (#9738) Stop using the unused delivery_log and subscriptions tables (#9746) mobile: follow desktop's unified sidebar workspaces (#9745) fix(mobile): open message actions only from a long press on the message (#9753) Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com> # Conflicts: # mobile/lib/features/channels/channel_directory.dart # mobile/lib/features/channels/channel_unread.dart
Summary
delivery_logandsubscriptionscame with the initial schema for a delivery feature that was never built. No code has ever written to them. This PR removes every reader, writer, partition-manager entry and deletion selection, so a follow-up contract migration can drop both tables (docs/database.mdRule 5: drop only after the release that stops using a table is fully deployed).eventsonly. It no longer creates or auditsdelivery_logpartitions.EXPECTED_SCOPED_TABLES/PURGE_SCOPED_TABLESto a newRETIRING_SCOPED_TABLESlist. The catalog accepts each one present or absent. The purge deletes its rows only while it exists.validate_approved_schemaaccepts a frozen retiring table that has since been dropped, and no other missing table. Without this, every community deletion would fail its exact catalog check once the tables are gone.docs/database.md, plus partition-monitoring and cleanup docs.The tables, their schema files,
.pgschemaignoreentries and the partition primary-key lint exception stay until the drop migration.Rollout
delivery_logto exist must update it first.The partition audit stops emitting
buzz_partition_audit_*series withtable="delivery_log". Alerts keyed on that label will go quiet.What got simpler
Two tables' worth of code paths are gone: partition management, the audit, and five deletion handlers stop special-casing them. The follow-up removes the tables and the
RETIRING_SCOPED_TABLESentries.Testing
On a remote workstation at
3675ff17:cargo fmt --check,clippy -D warningsfor buzz-db, buzz-deletion and buzz-relay (all targets), unit tests for buzz-db (lib and tests), buzz-deletion and buzz-relay bins, andscripts/postgres-test-run.shfor buzz-db partition/deletion/migration tests (294 passed) and all buzz-deletion Postgres tests (44 passed). The new tests cover: retiring tables purged and verified while present; a request inventoried before a realDROP TABLEstill purges and verifies;validate_approved_schematolerates only retiring tables vanishing.🤖 Generated with Claude Code