From 4431631ab1011ec98ac1e478920989e56303bab5 Mon Sep 17 00:00:00 2001 From: Luke Tornquist Date: Tue, 17 Nov 2026 14:52:47 -0500 Subject: [PATCH] buzz-db: stop calling the dropped lock-key function in SQL #9363 added a SQL caller of `community_deletion_lock_key` in user content cleanup after #9396 moved the key to Rust. Migration 0094 drops the function, so that cleanup fails with 42883 on any database at 0094. Bind the Rust-built key with `hashtextextended`, as every other caller does. The deployment doc now says builds with that caller are not valid stops before 0094. Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 Signed-off-by: Luke Tornquist --- .../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 e76f0704e18..a089bc57f11 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 985f03ea0fa..bf25b4df558 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 b1b09832ba1..72759f345d6 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`.