pglite icon indicating copy to clipboard operation
pglite copied to clipboard

pg_advisory_lock is not waiting for unlock

Open atinseau opened this issue 7 months ago • 1 comments

To reproduce:

SELECT pg_advisory_lock(123);

-- Now a new lock appear in pg_locks SELECT * FROM pg_locks WHERE locktype = 'advisory' AND objid = 123;

SELECT pg_advisory_lock(123); -- IS NOT WAITING, just a new lock in the pg_locks appear

-- to clear, pg_locks, pg_advisory_unlock must be called twice (it's not the right behavior...) SELECT pg_advisory_unlock(123);

SELECT * FROM pg_locks WHERE locktype = 'advisory' AND objid = 123; -- still presente

SELECT pg_advisory_unlock(123);

SELECT * FROM pg_locks WHERE locktype = 'advisory' AND objid = 123; -- now empty

atinseau avatar Jun 18 '25 12:06 atinseau

pglite only supports one exclusive connection, i.e. you can't have multiple concurrent tx that can lock each other.

https://github.com/electric-sql/pglite?tab=readme-ov-file#how-it-works

I guess you see the PG behaviour in this pg "single user mode"?

czeidler avatar Jun 23 '25 00:06 czeidler