0

我不是死锁方面的专家,但我所看到的对我来说不太有意义。似乎两个不同的进程在同一个对象上死锁。难道不是一个进程只是等待资源被释放并继续它的生命吗?通常死锁涉及2个资源,这就是我感到困惑的原因。

僵局:

<deadlock-list>
 <deadlock victim="process53f288">
  <process-list>
   <process id="process53f288" taskpriority="0" logused="264" waitresource="KEY: 7:72057594065977344 (651c594e0a33)" waittime="4406" ownerId="293044707" transactionname="user_transaction" lasttranstarted="2013-10-03T15:41:21.040" XDES="0x80cd53c0" lockMode="X" schedulerid="1" kpid="14284" status="suspended" spid="92" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2013-10-03T15:41:21.560" lastbatchcompleted="2013-10-03T15:41:21.553" clientapp=".Net SqlClient Data Provider" hostname="MCCMTLMCS001" hostpid="2952" loginname="asapdb" isolationlevel="read committed (2)" xactid="293044707" currentdb="7" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
    <executionStack>
     <frame procname="adhoc" line="1" stmtstart="34" sqlhandle="0x0200000065487b054151f9a8d40f9f90d40cba7ff11e6228">
UPDATE InnoPickCaseList SET DestinationSpiral = @p0 WHERE Sequence = @p1     </frame>
     <frame procname="unknown" line="1" sqlhandle="0x000000000000000000000000000000000000000000000000">
unknown     </frame>
    </executionStack>
    <inputbuf>
(@p0 int,@p1 int)UPDATE InnoPickCaseList SET DestinationSpiral = @p0 WHERE Sequence = @p1    </inputbuf>
   </process>
   <process id="process7ed948" taskpriority="0" logused="4556" waitresource="KEY: 7:72057594065977344 (62b5bdcd3e80)" waittime="4403" ownerId="293044717" transactionname="user_transaction" lasttranstarted="2013-10-03T15:41:21.050" XDES="0x1298df950" lockMode="X" schedulerid="4" kpid="7344" status="suspended" spid="94" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2013-10-03T15:41:21.560" lastbatchcompleted="2013-10-03T15:41:21.557" clientapp=".Net SqlClient Data Provider" hostname="MCCMTLMCS001" hostpid="2952" loginname="asapdb" isolationlevel="read committed (2)" xactid="293044717" currentdb="7" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
    <executionStack>
     <frame procname="adhoc" line="1" stmtstart="34" sqlhandle="0x0200000065487b054151f9a8d40f9f90d40cba7ff11e6228">
UPDATE InnoPickCaseList SET DestinationSpiral = @p0 WHERE Sequence = @p1     </frame>
     <frame procname="unknown" line="1" sqlhandle="0x000000000000000000000000000000000000000000000000">
unknown     </frame>
    </executionStack>
    <inputbuf>
(@p0 int,@p1 int)UPDATE InnoPickCaseList SET DestinationSpiral = @p0 WHERE Sequence = @p1    </inputbuf>
   </process>
  </process-list>
  <resource-list>
   <keylock hobtid="72057594065977344" dbid="7" objectname="ExactaDB.dbo.InnoPickCaseList" indexname="PK_InnoPickCaseList" id="locka7110b00" mode="X" associatedObjectId="72057594065977344">
    <owner-list>
     <owner id="process7ed948" mode="X"/>
    </owner-list>
    <waiter-list>
     <waiter id="process53f288" mode="X" requestType="wait"/>
    </waiter-list>
   </keylock>
   <keylock hobtid="72057594065977344" dbid="7" objectname="ExactaDB.dbo.InnoPickCaseList" indexname="PK_InnoPickCaseList" id="lockbb807a80" mode="X" associatedObjectId="72057594065977344">
    <owner-list>
     <owner id="process53f288" mode="X"/>
    </owner-list>
    <waiter-list>
     <waiter id="process7ed948" mode="X" requestType="wait"/>
    </waiter-list>
   </keylock>
  </resource-list>
 </deadlock>
</deadlock-list>

图形

在此处输入图像描述

额外细节

  • InnoPickCaseList.Sequence 是表的主键,它有一个聚集索引
  • 表通常包含大约 10k 条记录

我认为问题的发生是因为特定应用程序进行更新的方式。本质上,有两个不同的线程可以更新事务中的同一组数据(InnoPickCaseList.Sequence 数字的范围),但它可能以不同的顺序进行更新。在这一点上,我进行了更改,以便在两个不同的线程中以相同的方式对数据进行排序,以便更新将以相同的顺序发生。

4

1 回答 1

1

有两种不同的资源。一个是带有 hash 的 key,a7110b00另一个是带有 hash 的 key bb807a80。确实它们属于同一个对象ExactaDB.dbo.InnoPickCaseList.PK_InnoPickCaseList,但它们仍然不同。

  1. 你有索引Sequence吗?
  2. 列的选择性是什么Sequence(有多少不同的值)?
  3. 有多大InnoPickCaseList
于 2013-10-04T13:37:47.873 回答