アドバイザリーロック
Session A │ Session B
================================================================================================
=> BEGIN; UPDATE t1 SET n = 101 WHERE id = 1 R│=>
ETURNING pg_try_advisory_xact_lock(id); │=>
BEGIN │=>
pg_try_advisory_xact_lock │=>
--------------------------- │=>
t │=>
(1 row) │=>
│=>
=*> │=> BEGIN; SELECT * FROM t1 WHERE id = 1 AND pg_
│try_advisory_xact_lock(1);
│BEGIN
│ id | n
│----+---
│(0 rows)
│
│=*>
=*> COMMIT; │=*>
=> │=*> SELECT * FROM t1 WHERE id = 1 AND pg_try_ad
=> │visory_xact_lock(1);
│ id | n
│----+-----
│ 1 | 101
│(1 row)
│
│=*>
参考