Skip to content

Stop using the unused delivery_log and subscriptions tables - #9746

Merged
TheSentinel454 merged 5 commits into
mainfrom
elrond/retire-delivery-tables-code
Nov 20, 2026
Merged

TheSentinel454 merged 5 commits into
mainfrom
elrond/retire-delivery-tables-code

Conversation

@TheSentinel454

Copy link
Copy Markdown
Contributor

Summary

delivery_log and subscriptions came 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.md Rule 5: drop only after the release that stops using a table is fully deployed).

  • Partition manager: manages events only. It no longer creates or audits delivery_log partitions.
  • User deletion: the content, account and profile handlers no longer select, delete or recheck rows in either table.
  • Community deletion: both tables move from EXPECTED_SCOPED_TABLES/PURGE_SCOPED_TABLES to a new RETIRING_SCOPED_TABLES list. The catalog accepts each one present or absent. The purge deletes its rows only while it exists. validate_approved_schema accepts 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: a short "Retiring a tenant-owned table" section in docs/database.md, plus partition-monitoring and cleanup docs.

The tables, their schema files, .pgschemaignore entries and the partition primary-key lint exception stay until the drop migration.

Rollout

  1. Deploy this release to every relay, deletion executor and operator CLI. Older binaries fail community deletion's exact catalog check after the drop.
  2. Then ship the drop migration and remove the schema entries. Operators with external tooling that expects delivery_log to exist must update it first.

The partition audit stops emitting buzz_partition_audit_* series with table="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_TABLES entries.

Testing

On a remote workstation at 3675ff17: cargo fmt --check, clippy -D warnings for buzz-db, buzz-deletion and buzz-relay (all targets), unit tests for buzz-db (lib and tests), buzz-deletion and buzz-relay bins, and scripts/postgres-test-run.sh for 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 real DROP TABLE still purges and verifies; validate_approved_schema tolerates only retiring tables vanishing.

🤖 Generated with Claude Code

@TheSentinel454
TheSentinel454 marked this pull request as ready for review November 19, 2026 21:21
@TheSentinel454
TheSentinel454 force-pushed the elrond/retire-delivery-tables-code branch from 3675ff1 to 5ee49f6 Compare November 19, 2026 21:23

@wpfleger96 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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_present looks up the subscriptions → users foreign key with fetch_one and panics with RowNotFound at .expect("subscriptions owner foreign key"). A Postgres run of main + #9740 + this PR reproduced it. The fix is to drop the lookup-and-DROP CONSTRAINT step and insert the straggler rows directly.
  • The profile-cleanup guard added in d5837d81 exists 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 with retained_subscription_blocks_until_the_table_is_dropped and the subscriptions paragraph in docs/profile-cleanup.md.
  • The RETIRING_SCOPED_TABLES doc comment says purging these tables ahead of PURGE_SCOPED_TABLES "satisfies the foreign key from subscriptions to users". 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 brow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

TheSentinel454 and others added 5 commits November 19, 2026 18:27
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>
@TheSentinel454
TheSentinel454 force-pushed the elrond/retire-delivery-tables-code branch from d4bbca7 to 11ac1e8 Compare November 19, 2026 23:28
@TheSentinel454

Copy link
Copy Markdown
Contributor Author

🤖 Updated onto main (with #9740) at 11ac1e8:

  • retiring_scoped_tables_are_purged_and_verified_while_present no longer looks up or drops the subscriptions foreign key. It inserts the stragglers directly.
  • Removed the profile-cleanup subscriptions guard, its test retained_subscription_blocks_until_the_table_is_dropped, and the doc paragraph in docs/profile-cleanup.md.

The PostgreSQL lanes are running on the merged tree now.

@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 19, 2026
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 69ea27343c9b60eeeb1f6e903529cd8b789e910e...11ac1e8de8cc0c562f76daef7c3506353edaed48
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings were identified in the authorized PR range.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review was limited to read-only source, migration, test, caller, and history inspection. Builds and tests were not executed, as requested.

Generated by Codex Security Review |
Requested by: @TheSentinel454 |
Workflow run

@wpfleger96 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

@TheSentinel454
TheSentinel454 merged commit 7e94503 into main Nov 20, 2026
91 checks passed
@TheSentinel454
TheSentinel454 deleted the elrond/retire-delivery-tables-code branch November 20, 2026 03:19
morgmart added a commit that referenced this pull request Nov 20, 2026
…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

This branch was successfully deployed

1 active deployment
codex-review — 11ac1e8d Deployed Nov 19, 2026 by TheSentinel454 via Run Codex Security Review #16554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants