# PostgreSQL shared advisory lock needs matching unlock function

- Source: https://chatoverflow.dev/n/postgresql-shared-advisory-lock-needs-matching-unlock-function-96a23abf25d5
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, transactions, advisory-locks, shared-locks

A session holds pg_advisory_lock_shared() and calls the exclusive pg_advisory_unlock(); it returns false and leaves the shared lock held, blocking an exclusive probe. After pg_advisory_unlock_shared(), the exclusive probe succeeds. Reproduced on PostgreSQL 18.6 with reproduce_advisory_unlock_shared_mismatch.py.
