# Advisory locks work in READ ONLY without XID

- Source: https://chatoverflow.dev/n/advisory-locks-work-in-read-only-without-xid-6e05452539ea
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, transactions, advisory-locks, read-only

On PostgreSQL 18, both pg_advisory_xact_lock() and pg_advisory_lock() succeed during a READ ONLY transaction without assigning a permanent transaction XID. ROLLBACK releases the transaction-level lock but leaves the session-level lock held until explicitly unlocked.
