我需要一些帮助来理解为什么在我的数据库的特定表上发生特定的死锁。我知道很少的死锁,特别是死在同一张桌子上。
你可以帮助解决这个僵局吗?我不是在寻找具体的解决方案,我只是想知道为什么会出现这种僵局:
<deadlock-list>
<deadlock victim="process4aa5b88">
<process-list>
<process id="process4aa5b88" taskpriority="0" logused="0" waitresource="PAGE: 14:1:6535"
waittime="4912" ownerId="260658" transactionname="UPDATE" lasttranstarted="2015-02-10T09:35:10.040"
XDES="0x8006bb70" lockMode="U" schedulerid="8" kpid="2804" status="suspended" spid="221" sbid="0" ecid="5"
priority="0" trancount="0" lastbatchstarted="2015-02-10T09:35:09.993"
lastbatchcompleted="2015-02-10T09:35:09.993" clientapp=".Net SqlClient Data Provider" hostname="ANP-APP"
hostpid="6728" isolationlevel="read committed (2)" xactid="260658" currentdb="14" lockTimeout="4294967295"
clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="2" sqlhandle="0x02000000c7f3e035aa74a68d308785ac6386d1ee4b1f924e">
UPDATE ic_seguimiento_contenedor SET nave_id = M.id_interno, nave_nombre=M.campo2 FROM mantenedor_general M WHERE ic_seguimiento_contenedor.nave_id = 0 AND ic_seguimiento_contenedor.estado_cod<20 AND M.id_empresa=ic_seguimiento_contenedor.id_empresa AND ic_seguimiento_contenedor.id_empresa=105 AND M.mantenedor='mant_nave' AND ltrim(rtrim(M.campo1))=ltrim(rtrim(ic_seguimiento_contenedor.nave_cod)) AND ic_seguimiento_contenedor.key_negocio ='53E010566725403' </frame>
</executionStack>
<inputbuf> </inputbuf>
</process>
<process id="process4a8b288" taskpriority="0" logused="0" waitresource="PAGE: 14:1:6535"
waittime="6287" ownerId="260658" transactionname="UPDATE" lasttranstarted="2015-02-10T09:35:10.040"
XDES="0xbf9597b0" lockMode="U" schedulerid="7" kpid="6952" status="suspended" spid="221" sbid="0" ecid="7"
priority="0" trancount="0" lastbatchstarted="2015-02-10T09:35:09.993"
lastbatchcompleted="2015-02-10T09:35:09.993" clientapp=".Net SqlClient Data Provider" hostname="ANP-APP"
hostpid="6728" isolationlevel="read committed (2)" xactid="260658" currentdb="14" lockTimeout="4294967295"
clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="2" sqlhandle="0x02000000c7f3e035aa74a68d308785ac6386d1ee4b1f924e">
UPDATE ic_seguimiento_contenedor SET nave_id = M.id_interno, nave_nombre=M.campo2 FROM mantenedor_general M WHERE ic_seguimiento_contenedor.nave_id = 0 AND ic_seguimiento_contenedor.estado_cod<20 AND M.id_empresa=ic_seguimiento_contenedor.id_empresa AND ic_seguimiento_contenedor.id_empresa=105 AND M.mantenedor='mant_nave' AND ltrim(rtrim(M.campo1))=ltrim(rtrim(ic_seguimiento_contenedor.nave_cod)) AND ic_seguimiento_contenedor.key_negocio ='53E010566725403' </frame>
</executionStack>
<inputbuf> </inputbuf>
</process>
<process id="process463d948" taskpriority="0" logused="0" waitresource="PAGE: 14:1:6503"
waittime="4912" ownerId="260657" transactionname="UPDATE" lasttranstarted="2015-02-10T09:35:10.040"
XDES="0xb4595850" lockMode="U" schedulerid="4" kpid="2060" status="suspended" spid="219" sbid="0" ecid="3"
priority="0" trancount="0" lastbatchstarted="2015-02-10T09:35:09.993"
lastbatchcompleted="2015-02-10T09:35:09.993" clientapp=".Net SqlClient Data Provider" hostname="ANP-APP"
hostpid="6728" isolationlevel="read committed (2)" xactid="260657" currentdb="14" lockTimeout="4294967295"
clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="2" sqlhandle="0x02000000c7f3e035aa74a68d308785ac6386d1ee4b1f924e">
UPDATE ic_seguimiento_contenedor SET nave_id = M.id_interno, nave_nombre=M.campo2 FROM mantenedor_general M WHERE ic_seguimiento_contenedor.nave_id = 0 AND ic_seguimiento_contenedor.estado_cod<20 AND M.id_empresa=ic_seguimiento_contenedor.id_empresa AND ic_seguimiento_contenedor.id_empresa=105 AND M.mantenedor='mant_nave' AND ltrim(rtrim(M.campo1))=ltrim(rtrim(ic_seguimiento_contenedor.nave_cod)) AND ic_seguimiento_contenedor.key_negocio ='53E010566725403' </frame>
</executionStack>
<inputbuf> </inputbuf>
</process>
<process id="process449ebc8" taskpriority="0" logused="0" waitresource="PAGE: 14:1:6503"
waittime="6287" ownerId="260657" transactionname="UPDATE" lasttranstarted="2015-02-10T09:35:10.040"
XDES="0x80007a70" lockMode="U" schedulerid="1" kpid="6936" status="suspended" spid="219" sbid="0" ecid="5"
priority="0" trancount="0" lastbatchstarted="2015-02-10T09:35:09.993"
lastbatchcompleted="2015-02-10T09:35:09.993" clientapp=".Net SqlClient Data Provider" hostname="ANP-APP"
hostpid="6728" isolationlevel="read committed (2)" xactid="260657" currentdb="14" lockTimeout="4294967295"
clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="2" sqlhandle="0x02000000c7f3e035aa74a68d308785ac6386d1ee4b1f924e">
UPDATE ic_seguimiento_contenedor SET nave_id = M.id_interno, nave_nombre=M.campo2 FROM mantenedor_general M WHERE ic_seguimiento_contenedor.nave_id = 0 AND ic_seguimiento_contenedor.estado_cod<20 AND M.id_empresa=ic_seguimiento_contenedor.id_empresa AND ic_seguimiento_contenedor.id_empresa=105 AND M.mantenedor='mant_nave' AND ltrim(rtrim(M.campo1))=ltrim(rtrim(ic_seguimiento_contenedor.nave_cod)) AND ic_seguimiento_contenedor.key_negocio ='53E010566725403' </frame>
</executionStack>
<inputbuf> </inputbuf>
</process>
<process id="process4a8b048" taskpriority="0" logused="10000" waittime="4905" schedulerid="7" kpid="6324"
status="suspended" spid="219" sbid="0" ecid="0" priority="0" trancount="2"
lastbatchstarted="2015-02-10T09:35:09.993" lastbatchcompleted="2015-02-10T09:35:09.993"
clientapp=".Net SqlClient Data Provider" hostname="ANP-APP" hostpid="6728" loginname="sa"
isolationlevel="read committed (2)" xactid="260657" currentdb="14" lockTimeout="4294967295"
clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="2" sqlhandle="0x02000000c7f3e035aa74a68d308785ac6386d1ee4b1f924e">
UPDATE ic_seguimiento_contenedor SET nave_id = M.id_interno, nave_nombre=M.campo2 FROM mantenedor_general M WHERE ic_seguimiento_contenedor.nave_id = 0 AND ic_seguimiento_contenedor.estado_cod<20 AND M.id_empresa=ic_seguimiento_contenedor.id_empresa AND ic_seguimiento_contenedor.id_empresa=105 AND M.mantenedor='mant_nave' AND ltrim(rtrim(M.campo1))=ltrim(rtrim(ic_seguimiento_contenedor.nave_cod)) AND ic_seguimiento_contenedor.key_negocio ='53E010566725403' </frame>
</executionStack>
<inputbuf> UPDATE ic_seguimiento_contenedor SET nave_id = M.id_interno, nave_nombre=M.campo2 FROM mantenedor_general M WHERE ic_seguimiento_contenedor.nave_id = 0 AND ic_seguimiento_contenedor.estado_cod<20 AND M.id_empresa=ic_seguimiento_contenedor.id_empresa AND ic_seguimiento_contenedor.id_empresa=105 AND M.mantenedor='mant_nave' AND ltrim(rtrim(M.campo1))=ltrim(rtrim(ic_seguimiento_contenedor.nave_cod)) AND ic_seguimiento_contenedor.key_negocio ='53E010566725403' </inputbuf>
</process>
</process-list>
<resource-list>
<pagelock fileid="1" pageid="6535" dbid="14" objectname="icomexvi_dys.dbo.ic_seguimiento_contenedor" id="lock95e1e800" mode="U" associatedObjectId="72057594108248064">
<owner-list/>
<waiter-list>
<waiter id="process4aa5b88" mode="U" requestType="wait"/>
</waiter-list>
</pagelock>
<pagelock fileid="1" pageid="6535" dbid="14" objectname="icomexvi_dys.dbo.ic_seguimiento_contenedor" id="lock95e1e800" mode="U" associatedObjectId="72057594108248064">
<owner-list>
<owner id="process4a8b048" mode="U"/>
</owner-list>
<waiter-list>
<waiter id="process4a8b288" mode="U" requestType="wait"/>
</waiter-list>
</pagelock>
<pagelock fileid="1" pageid="6503" dbid="14" objectname="icomexvi_dys.dbo.ic_seguimiento_contenedor" id="lock96c23080" mode="U" associatedObjectId="72057594108248064">
<owner-list/>
<waiter-list>
<waiter id="process463d948" mode="U" requestType="wait"/>
</waiter-list>
</pagelock>
<pagelock fileid="1" pageid="6503" dbid="14" objectname="icomexvi_dys.dbo.ic_seguimiento_contenedor" id="lock96c23080" mode="U" associatedObjectId="72057594108248064">
<owner-list>
<owner id="process4aa5b88" mode="U"/>
</owner-list>
<waiter-list>
<waiter id="process449ebc8" mode="U" requestType="wait"/>
</waiter-list>
</pagelock>
<exchangeEvent id="Pipec6a2eac0" WaitType="e_waitPipeGetRow" nodeId="4">
<owner-list>
<owner id="process463d948"/>
</owner-list>
<waiter-list>
<waiter id="process4a8b048"/>
</waiter-list>
</exchangeEvent>
</resource-list>
</deadlock>
</deadlock-list>
非常感谢您的帮助! 提前致谢
答案 0 :(得分:2)
以下是流程:process4aa5b88
,process4a8b288
,process463d948
,process449ebc8
和process4a8b048
。
Page 6535归process4a8b048
所有,并由process4aa5b88
和process4a8b288
等待。
页面6503归process4aa5b88
所有,并由process449ebc8
和process463d948
等待。
并行交换管Pipec6a2eac0
归process463d948
所有,并由process4a8b048
等待。
死锁循环是这样的:
process4aa5b88
等待process4a8b048
process4a8b048
等待process463d948
process463d948
等待process4aa5b88
QED等待名单中的一个周期=&gt;死锁
扫描期间存在并行性和页面粒度锁定是缺少索引的明确指示。查看WHERE子句,确保您有SARGable参数。阅读Index Design Basics和所有相关章节。