我有两个死锁的 SQL 选择语句。我的印象是选择不能相互死锁?
令人费解的是,查询在 select 语句上采用了页面锁,索引会导致这种情况吗?
<deadlock-list>
<deadlock victim="process1cf0ce928">
<process-list>
<process id="process1cf0ce928" taskpriority="0" logused="8580" waitresource="PAGE: 11:1:168082 " waittime="4116" ownerId="24335138" transactionname="user_transaction" lasttranstarted="2013-10-01T23:04:04.353" XDES="0x2aa2f8d28" lockMode="S" schedulerid="2" kpid="6356" status="suspended" spid="62" sbid="0" ecid="0" priority="0" trancount="1" lastbatchstarted="2013-10-01T23:04:06.907" lastbatchcompleted="2013-10-01T23:04:06.903" lastattention="1900-01-01T00:00:00.903" clientapp=".Net SqlClient Data Provider" hostname="******" hostpid="5892" loginname="*****" isolationlevel="read committed (2)" xactid="24335138" currentdb="11" lockTimeout="4294967295" clientoption1="673185824" clientoption2="128056">
<executionStack>
<frame procname="DB.dbo.GetCommandById" line="22" stmtstart="1586" stmtend="1726" sqlhandle="0x03000b00edb44b1eebd677013da2000001000000000000000000000000000000000000000000000000000000">
SELECT Top 1 *
FROM [Commands]
WHERE [Command_ID] = @CmdId; </frame>
</executionStack>
<inputbuf>
Proc [Database Id = 11 Object Id = 508277997] </inputbuf>
</process>
<process id="process1caa24cf8" taskpriority="0" logused="9876" waitresource="PAGE: 11:1:168082 " waittime="4104" ownerId="24335088" transactionname="user_transaction" lasttranstarted="2013-10-01T23:04:04.180" XDES="0x24f9956a8" lockMode="S" schedulerid="2" kpid="3872" status="suspended" spid="52" sbid="0" ecid="0" priority="0" trancount="1" lastbatchstarted="2013-10-01T23:04:06.917" lastbatchcompleted="2013-10-01T23:04:06.903" lastattention="1900-01-01T00:00:00.903" clientapp=".Net SqlClient Data Provider" hostname="*****" hostpid="5892" loginname="*****" isolationlevel="read committed (2)" xactid="24335088" currentdb="11" lockTimeout="4294967295" clientoption1="673185824" clientoption2="128056">
<executionStack>
<frame procname="DB.dbo.GetCommandById" line="22" stmtstart="1586" stmtend="1726" sqlhandle="0x03000b00edb44b1eebd677013da2000001000000000000000000000000000000000000000000000000000000">
SELECT Top 1 *
FROM [Commands]
WHERE [Command_ID] = @CmdId; </frame>
</executionStack>
<inputbuf>
Proc [Database Id = 11 Object Id = 508277997] </inputbuf>
</process>
</process-list>
<resource-list>
<pagelock fileid="1" pageid="168082" dbid="11" subresource="FULL" objectname="DB.dbo.Commands" id="lock22626c880" mode="IX" associatedObjectId="72057795337322496">
<owner-list>
<owner id="process1caa24cf8" mode="IX"/>
<owner id="process1caa24cf8" mode="S" requestType="convert"/>
</owner-list>
<waiter-list>
<waiter id="process1cf0ce928" mode="S" requestType="convert"/>
</waiter-list>
</pagelock>
<pagelock fileid="1" pageid="168082" dbid="11" subresource="FULL" objectname="DB.dbo.Commands" id="lock22626c880" mode="IX" associatedObjectId="72057795337322496">
<owner-list>
<owner id="process1cf0ce928" mode="IX"/>
<owner id="process1cf0ce928" mode="S" requestType="convert"/>
</owner-list>
<waiter-list>
<waiter id="process1caa24cf8" mode="S" requestType="convert"/>
</waiter-list>
</pagelock>
</resource-list>
</deadlock>
</deadlock-list>