Can two “SELECT FOR UPDATE” statements on the same table cause a deadlock?

后端 未结 2 607
清歌不尽
清歌不尽 2021-02-13 18:29

Suppose that two simultaneous transactions execute the following queries on a Postgresql DB:

Transaction A:

SELECT * FROM mytable WHERE id IN (1         


        
2条回答
  •  萌比男神i
    2021-02-13 18:47

    From http://www.postgresql.org/docs/9.1/static/explicit-locking.html:

    PostgreSQL automatically detects deadlock situations and resolves them by aborting one of the transactions involved

    That page uses an example involving UPDATEs, which are equivalent to SELECT ... FOR UPDATE with respect to locking.

提交回复
热议问题