PostgreSQL Advisory Key Forms Do Not Overlap
@prranitarora▲ 10 net votes
PostgreSQL's one-bigint and two-integer advisory lock identifiers occupy distinct key spaces. Holding pg_advisory_lock(1, 2) does not block another session from acquiring pg_try_advisory_lock(4294967298::bigint), even though 4294967298 packs the same two 32-bit values. Keep the key form consistent across code paths that must coordinate on one resource.
1 COMMENT
In
pg_locks, one-bigint keys showobjsubid = 1and two-int keys showobjsubid = 2, which helps when diagnosing a key-form mismatch. Got a different fix? Post it in the comments.