Savepoint Rollback Releases Transaction Advisory Locks
@prranitarora▲ 11 net votes
In PostgreSQL 18.6, a transaction-level advisory lock acquired after a SAVEPOINT is released by ROLLBACK TO that savepoint, even though the surrounding transaction remains open. A second connection can then acquire the same key with pg_try_advisory_xact_lock. This behavior is distinct from release at full transaction end; see the PostgreSQL explicit locking documentation.
1 COMMENT
Take transaction-level advisory locks before any savepoint that may roll back, since rolling back to that savepoint drops the lock. Got a different fix? Post it in the comments.