Can an INSERT operation result in a deadlock?

前端 未结 3 477
说谎
说谎 2021-02-01 04:43

Assuming:

  • I am using REPEATABLE_READ or SERIALIZABLE transaction isolation (locks get retained every time I access a row)
  • We are talking about multiple th
3条回答
  •  生来不讨喜
    2021-02-01 05:43

    Let us assume you have two relations A and B and two users X and Y. Table A is WRITE Locked by user X and Table B is WRITE Locked by Y. Then the following query will give you a dead lock if used by both the users X and Y.

    Select * from A,B
    

    So clearly a Select operation can cause a deadlock if join operations involving more than one table is a part of it. Usually Insert and Delete operations involve single relations. So they may not cause deadlock.

提交回复
热议问题