From 3f6250ea81209b24f9929559954b17253009db04 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Tue, 4 Aug 2026 22:44:07 +0100 Subject: [PATCH] Remove dead acquireAdvisoryXactLock try variant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The transaction-scoped TRY variant had no production callers — only the conn-level try-lock (acquireAdvisoryLock) and the blocking xact variant (acquireAdvisoryXactLockBlocking, used by the admin cancellation path) are in use. Dropping the dead code removes a foot-gun: a try-lock that silently fails to acquire inside a transaction would otherwise look like a safe option. --- backend/handlers/payments/locks.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/backend/handlers/payments/locks.go b/backend/handlers/payments/locks.go index 4dcabd5..d99020d 100644 --- a/backend/handlers/payments/locks.go +++ b/backend/handlers/payments/locks.go @@ -39,15 +39,8 @@ func acquireAdvisoryLock(ctx context.Context, conn *pgxpool.Conn, key string) (b return tryAdvisoryLock(ctx, conn, key, "pg_try_advisory_lock") } -// acquireAdvisoryXactLock is the transaction-scoped variant of -// acquireAdvisoryLock: the lock is held on the transaction and auto-released -// at commit/rollback, so the caller must NOT unlock explicitly. -func acquireAdvisoryXactLock(ctx context.Context, tx pgx.Tx, key string) (bool, error) { - return tryAdvisoryLock(ctx, tx, key, "pg_try_advisory_xact_lock") -} - // acquireAdvisoryXactLockBlocking is the transaction-scoped BLOCKING variant -// of acquireAdvisoryXactLock: it issues `SELECT pg_advisory_xact_lock(...)` +// of acquireAdvisoryLock: it issues `SELECT pg_advisory_xact_lock(...)` // ONCE and waits for as long as the key is contended — there is no 3s bound. // The lock is transaction-scoped, so it is auto-released at the caller's // commit/rollback (never unlocked explicitly).