Deadlock on 2 pages

依然范特西╮ 提交于 2019-12-05 22:48:46
Roji P Thomas

The following inferences made from the data provided,

  1. Both the transactions are running under read committed isolation level.
  2. One transaction is doing multiple individual row UPDATEs. This is evident from the fact that one of the process is holding an IX lock and waiting for another. As per the execution plan, the UPDATE statement is using a single row clustered index seek. So it will be acquiring an X lock at the KEY level and an IX lock at the page level.
  3. The SELECT statement and is acquiring locks at PAGE level granularity. Also the SELECT is retaining the locks after reading the pages. Under normal circumstances in READ COMMITTED ISOLATION LEVEL, a SELECT statement will acquire and release SHARED locks immediately after reading.

With these findings, I am almost certain that the deadlock is happening due to a special scenario involving a query optimization called UNORDERED PREFETCH. This is the only scenario I am aware of where SELECT statements running under READ COMMITTED Isolation level retains the SHARED locks until the end of the statement.

A repro and possible resolutions to this this type of deadlock can be found at https://web.archive.org/web/20120806214319/http://sqlindian.com/2012/07/13/deadlock-on-select-due-to-unordered-prefetch/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!