Advisory locks: private to connected database or shared across cluster


Is the space of keys in PostgreSQL advisory locks private to the connected database, or shared across the database cluster?

Nosing around and the answer doesn't seem to be obvious.

Best Answer

That is indeed not clear from the documentation, but a simple experiment shows that advisory locks are local to the database. That is, you can take the same advisory lock in two different databases without conflict.

Related Question