From 0a053307407fe89118e0e31c1c3dc040e18600cc Mon Sep 17 00:00:00 2001 From: Luke Tornquist Date: Tue, 17 Nov 2026 15:31:39 -0500 Subject: [PATCH] buzz-db: stop calling the dropped lock-key function in SQL (#9615) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Main's user content cleanup still calls the SQL function `community_deletion_lock_key`. Migration `0094` (#9598) drops it. On any database at `0094`, every user-deletion content batch fails with `42883 function community_deletion_lock_key(uuid) does not exist`. #9363 added this caller after #9396 moved the key to Rust. This PR binds the Rust-built key with `hashtextextended($1, 0)`, as every other caller does. - `content_batches/execute.rs`: the batch's exclusive advisory lock uses the Rust key. - `content_batches/safety_postgres_tests.rs`: the test blocker takes the same lock the same way. - `docs/trigger-retirement-deployment.md`: builds from #9363 up to this PR are not valid stops before `0094`. Rebased onto main `e894d75d`. The renumber and the `update_channel` test-call fixes this PR first carried are already on main through #9616, so they are gone from this PR. Deployed relays are unaffected: the deployed build predates #9363. ## Tests The 17 `user_deletion::content_batches` PostgreSQL tests fail on main at `0094` with the error above. This PR makes them pass. ## What got simpler One fewer SQL-side copy of the lock key. Every caller now builds the key in Rust. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Luke Tornquist Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 --- .../src/store/user_deletion/content_batches/execute.rs | 6 ++++-- .../content_batches/safety_postgres_tests.rs | 4 ++-- docs/trigger-retirement-deployment.md | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/buzz-db/src/store/user_deletion/content_batches/execute.rs b/crates/buzz-db/src/store/user_deletion/content_batches/execute.rs index e76f0704e1..a089bc57f1 100644 --- a/crates/buzz-db/src/store/user_deletion/content_batches/execute.rs +++ b/crates/buzz-db/src/store/user_deletion/content_batches/execute.rs @@ -136,8 +136,10 @@ pub(super) async fn execute_owned_batch( .await?; // Serving writers already hold the shared form of this lock. Keep the // exclusive section short: at most one bounded batch, never the whole run. - sqlx::query("SELECT pg_advisory_xact_lock(community_deletion_lock_key($1))") - .bind(community) + sqlx::query("SELECT pg_advisory_xact_lock(hashtextextended($1, 0))") + .bind(crate::deletion::community_deletion_lock_key( + crate::CommunityId::from_uuid(community), + )) .execute(&mut *tx) .await?; crate::deletion::guard_community_write(&mut tx, crate::CommunityId::from_uuid(community)) diff --git a/crates/buzz-db/src/store/user_deletion/content_batches/safety_postgres_tests.rs b/crates/buzz-db/src/store/user_deletion/content_batches/safety_postgres_tests.rs index 985f03ea0f..bf25b4df55 100644 --- a/crates/buzz-db/src/store/user_deletion/content_batches/safety_postgres_tests.rs +++ b/crates/buzz-db/src/store/user_deletion/content_batches/safety_postgres_tests.rs @@ -199,8 +199,8 @@ async fn reconnected_batch_still_bounds_lock_wait_and_loses_no_rows() { // The next batch must install its own limits on its replacement connection. session.acquire().await.unwrap().close().await.unwrap(); let mut blocker = db.pool().begin().await.unwrap(); - sqlx::query("SELECT pg_advisory_xact_lock(community_deletion_lock_key($1))") - .bind(c.as_uuid()) + sqlx::query("SELECT pg_advisory_xact_lock(hashtextextended($1, 0))") + .bind(crate::deletion::community_deletion_lock_key(c)) .execute(&mut *blocker) .await .unwrap(); diff --git a/docs/trigger-retirement-deployment.md b/docs/trigger-retirement-deployment.md index b1b09832ba..72759f345d 100644 --- a/docs/trigger-retirement-deployment.md +++ b/docs/trigger-retirement-deployment.md @@ -83,9 +83,12 @@ now does in application code: **A relay build at or after commit `279a31da` (the merge of [#9397](https://github.com/block/buzz/pull/9397), which follows #9396) and -before `0094` is a required stop.** No tagged relay release contains it: -`relay-v0.3.0` does not, so a deployment on a tagged release must move to a -stop build first. Follow the same procedure as above. An older relay that +before `0094` is a required stop.** Builds from commit `a8f55e63` (the merge +of [#9363](https://github.com/block/buzz/pull/9363)) up to the merge of +[#9615](https://github.com/block/buzz/pull/9615) do not qualify: their user +content cleanup still calls `community_deletion_lock_key`. No tagged relay +release is a stop build: `relay-v0.3.0` is not, so a deployment on a tagged +release must move to a stop build first. Follow the same procedure as above. An older relay that still serves after `0094` fails every write and deletion that takes the community deletion lock, with `42883 community_deletion_lock_key(uuid) does not exist`, and its profile name search fails with `42883 profile_name_fields(text) does not exist`.