我正在使用一些存储过程和死锁情况。
我一直在使用SQL Server Profiler,并以.xdl文件的形式从“死锁图”事件中获取有关死锁的一些信息。 低于该文件的内容。
我刚刚清除了有关该语句的一些信息。在.xdl中标记为<executionStack>
的语句是这样的(对于两个进程都是相同的语句):
SELECT SomeColumn, SomeColumn2
FROM SomeTable WITH (UPDLOCK)
INNER JOIN SomeTable2 ON SomeTable.SomeTable2ID = SomeTable2.SomeTable2ID
INNER JOIN SomeTable3 ON SomeTable2.SomeTable3ID = SomeTable3.SomeTable3ID
WHERE SomeColumn = @Something AND SomeColumn2 = @Something2
.xdl文件的内容:
<deadlock-list>
<deadlock victim="processc19dc8">
<process-list>
<process id="processc19dc8" taskpriority="0" logused="0" waitresource="KEY: 5:72057594042646528 (8194443284a0)" waittime="1541" ownerId="21923027" transactionname="user_transaction" lasttranstarted="2013-07-02T18:03:42.260" XDES="0x80051950" lockMode="RangeS-U" schedulerid="2" kpid="2712" status="suspended" spid="54" sbid="0" ecid="0" priority="0" trancount="1" lastbatchstarted="2013-07-02T18:03:42.260" lastbatchcompleted="2013-07-02T18:03:42.260" clientapp=".Net SqlClient Data Provider" hostname="XXX" hostpid="2148" loginname="XXX" isolationlevel="serializable (4)" xactid="21923027" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
...
</process>
<process id="processc4d048" taskpriority="0" logused="0" waitresource="KEY: 5:72057594042646528 (a0c936a3c965)" waittime="1541" ownerId="21923023" transactionname="user_transaction" lasttranstarted="2013-07-02T18:03:42.260" XDES="0x80049800" lockMode="RangeS-U" schedulerid="4" kpid="2492" status="suspended" spid="53" sbid="0" ecid="0" priority="0" trancount="1" lastbatchstarted="2013-07-02T18:03:42.260" lastbatchcompleted="2013-07-02T18:03:42.260" clientapp=".Net SqlClient Data Provider" hostname="XXX" hostpid="2148" loginname="XXX" isolationlevel="serializable (4)" xactid="21923023" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
...
</process>
</process-list>
<resource-list>
<keylock hobtid="72057594042646528" dbid="5" objectname="dbo.SomeTable" indexname="PK_SomeTable" id="lock83d99200" mode="RangeS-U" associatedObjectId="72057594042646528">
<owner-list>
<owner id="processc4d048" mode="RangeS-U"/>
</owner-list>
<waiter-list>
<waiter id="processc19dc8" mode="RangeS-U" requestType="wait"/>
</waiter-list>
</keylock>
<keylock hobtid="72057594042646528" dbid="5" objectname="dbo.SomeTable" indexname="PK_SomeTable" id="lock89b52900" mode="U" associatedObjectId="72057594042646528">
<owner-list>
<owner id="processc19dc8" mode="U"/>
</owner-list>
<waiter-list>
<waiter id="processc4d048" mode="RangeS-U" requestType="wait"/>
</waiter-list>
</keylock>
</resource-list>
</deadlock>
</deadlock-list>
所以看起来第一个进程拥有一个mode=U
的资源,第二个进程拥有mode=RangeS-U
的相同资源。
如果这两种模式彼此不兼容(根据compatibility matrix),怎么可能?