通过从其他表中进行级联删除来异步删除行。 解决死锁的方法是什么?相关表行可以锁定在事务中吗?
这是xml报告:
<deadlock>
<victim-list>
<victimProcess id="process1f5b50928" />
</victim-list>
<process-list>
<process id="process1f5b50928" taskpriority="0" logused="288" waitresource="KEY: 81:72057594039107584 (8194443284a0)" waittime="5575" ownerId="1131789084" transactionname="user_transaction" lasttranstarted="2019-03-18T10:24:30.773" XDES="0x1b36356a8" lockMode="RangeS-U" schedulerid="2" kpid="3604" status="suspended" spid="134" sbid="2" ecid="0" priority="0" trancount="3" lastbatchstarted="2019-03-18T10:24:30.790" lastbatchcompleted="2019-03-18T10:24:30.790" lastattention="1900-01-01T00:00:00.790" clientapp=".Net SqlClient Data Provider" hostpid="21004" isolationlevel="read uncommitted (1)" xactid="1131789084" currentdb="81" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" sqlhandle="0x0200000064c34002e8fa5b7dac17b29471b98d1653a1e03a0000000000000000000000000000000000000000">
(@1 int)DELETE [dbo].[Users] WITH(rowlock) WHERE [Id]=@1 </frame>
<frame procname="adhoc" line="1" sqlhandle="0x020000001485b7340562f882a8e2556c22adf5f74806757d0000000000000000000000000000000000000000">
DELETE FROM [dbo].[Users] WITH (ROWLOCK) WHERE Id IN (723540); </frame>
</executionStack>
<inputbuf>
DELETE FROM [dbo].[Users] WITH (ROWLOCK) WHERE Id IN (723540); </inputbuf>
</process>
<process id="process252569c38" taskpriority="0" logused="288" waitresource="PAGE: 81:1:564854 " waittime="4416" ownerId="1131789067" transactionname="user_transaction" lasttranstarted="2019-03-18T10:24:30.703" XDES="0x1addc76a8" lockMode="S" schedulerid="1" kpid="5568" status="suspended" spid="76" sbid="2" ecid="0" priority="0" trancount="3" lastbatchstarted="2019-03-18T10:24:30.757" lastbatchcompleted="2019-03-18T10:24:30.730" lastattention="1900-01-01T00:00:00.730" clientapp=".Net SqlClient Data Provider" hostpid="21004" isolationlevel="read uncommitted (1)" xactid="1131789067" currentdb="81" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" sqlhandle="0x0200000064c34002e8fa5b7dac17b29471b98d1653a1e03a0000000000000000000000000000000000000000">
(@1 int)DELETE [dbo].[Users] WITH(rowlock) WHERE [Id]=@1 </frame>
<frame procname="adhoc" line="1" sqlhandle="0x020000004cb6d313b5f743b8f2df7ba8dfe667de5ac86d290000000000000000000000000000000000000000">
DELETE FROM [dbo].[Users] WITH (ROWLOCK) WHERE Id IN (723537); </frame>
</executionStack>
<inputbuf>
DELETE FROM [dbo].[Users] WITH (ROWLOCK) WHERE Id IN (723537); </inputbuf>
</process>
</process-list>
<resource-list>
<keylock hobtid="72057594039107584" dbid="81" objectname=".dbo.ABSENTSTATUSES" indexname="PK__ABSENTST__3214EC07EB7F77EE" id="lock1df18ec00" mode="RangeS-U" associatedObjectId="72057594039107584">
<owner-list>
<owner id="process252569c38" mode="RangeS-U" />
</owner-list>
<waiter-list>
<waiter id="process1f5b50928" mode="RangeS-U" requestType="wait" />
</waiter-list>
</keylock>
<pagelock fileid="1" pageid="564854" dbid="81" subresource="FULL" objectname=".dbo.Users" id="lock2c6111980" mode="IX" associatedObjectId="72057594039042048">
<owner-list>
<owner id="process1f5b50928" mode="IX" />
</owner-list>
<waiter-list>
<waiter id="process252569c38" mode="S" requestType="convert" />
</waiter-list>
</pagelock>
</resource-list>
</deadlock>
这是死锁图: