You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A repeated claim that fails before pg_try_advisory_lock still unlocks the key #39
A repeated claim that fails before pg_try_advisory_lock runs still unlocks the key. An owner claims again after an earlier claim finished past its caller's 15 s timeout; with defaults that needs several queued claims that each end under 15 s, otherwise a lock_timeout or statement_timeout below 15 s set through :parameters. If that repeated claim then fails early (such a timeout while a table lock on subscriptions is held, or a pg_cancel_backend of the waiting claim), it still runs the unlock: the server keeps the owner's record while PostgreSQL holds nothing, and another session's claim succeeds. Shown on the lock server API in 12 of 12 cases, 3 of them reaching the repeated claim through a claim that outlived a 2.5 s caller timeout, with lock_timeout 1 s; at 19072b4 the hold stayed. Very low with defaults, low where lock_timeout or statement_timeout is set below 15 s.
Fixed by #60. A repeated claim that fails before pg_try_advisory_lock runs no longer unlocks the key its owner still holds.
Verified with test/advisory_locks_test.exs ("should keep the lock held when a repeated claim cannot wait for a table lock" and "should keep the lock held when a repeated claim is cancelled while it waits"): both fail against the code before #60 and pass on main.
Activity
yordis commentedon Oct 27, 2026
Fixed by #60. A repeated claim that fails before
pg_try_advisory_lockruns no longer unlocks the key its owner still holds.Verified with
test/advisory_locks_test.exs("should keep the lock held when a repeated claim cannot wait for a table lock" and "should keep the lock held when a repeated claim is cancelled while it waits"): both fail against the code before #60 and pass on main.