buzz-db: stop calling the dropped lock-key function in SQL (#9615)

## 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 <tornquist@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Luke Tornquist
2026-11-17 15:31:39 -05:00
committed by GitHub
parent 8fb0de8d53
commit 0a05330740
3 changed files with 12 additions and 7 deletions

View File

@@ -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))

View File

@@ -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();

View File

@@ -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`.