使用Service Broker时出现死锁问题
我有一个要求,我必须创建多个更新并插入一组表格 为此,正在调用主存储过程,其中将调用多个存储过程 在嵌套事务中,基于一组收到处理的数据。 逐个调用主程序很慢,这就是我们使用Service Broker的原因 在主存储过程中,它将调用几个存储过程,这些过程将记录插入3个表并更新3个其他存储过程 涉及的所有表都已编入索引。我正在使用Service Broker,但面临死锁情况。每个SP呼叫始终在唯一记录上工作。
死锁图中的详细信息
<Column name="TextData" id="1">
<deadlock-list>
<deadlock victim="process387bab0">
<process-list>
<process id="process387bab0" taskpriority="0" logused="50076" waitresource="KEY: 8:72057599133024256 (53975579c7be)"
waittime="3458" ownerId="1880362" transactionname="ACTIVATE_ENTITY" lasttranstarted="2012-04-16T12:56:06.713"
XDES="0x3d5cf590" lockMode="U" schedulerid="1" kpid="7036" status="background" spid="21" sbid="0" ecid="0"
priority="0" trancount="2">
<executionStack> <frame procname="unknown" sqlhandle="0x000000000000000000000000000000000000000000000000"> unknown </frame>
<frame procname="CMS.dbo.IntOnCaseCreationMessageReceive" line="102" stmtstart="6488" stmtend="6594"
sqlhandle="0x0300080076459b5a8f92150131a000000100000000000000"> EXECUTE [dbo].MasterSP @MessageBody, 1 </frame>
</executionStack> <inputbuf> </inputbuf> </process> <process id="process8588388" taskpriority="0" logused="64476"
waitresource="KEY: 8:72057599261540352 (9fea6888fb07)" waittime="1573" ownerId="1879248"
transactionname="ACTIVATE_ENTITY" lasttranstarted="2012-04-16T12:56:02.140" XDES="0xc313860"
lockMode="RangeS-S" schedulerid="1" kpid="7372" status="background" spid="20" sbid="0" ecid="0"
priority="0" trancount="2"> <executionStack> <frame procname="unknown" sqlhandle="0x000000000000000000000000000000000000000000000000"> unknown </frame>
<frame procname="CMS.dbo.IndividualSPToBeCalled" line="102" stmtstart="6488" stmtend="6594"
sqlhandle="0x0300080076459b5a8f92150131a000000100000000000000"> EXECUTE [dbo].IntCreateCases_SB @MessageBody, 1 </frame> </executionStack>
<inputbuf> </inputbuf> </process> </process-list> <resource-list> <keylock hobtid="72057599133024256" dbid="8"
objectname="CMS.dbo.TABLE1" indexname="PK_TABLE1" id="lock1e393540" mode="X" associatedObjectId="72057599133024256"> <owner-list>
<owner id="process8588388" mode="X"/> </owner-list> <waiter-list> <waiter id="process387bab0" mode="U" requestType="wait"/>
</waiter-list> </keylock> <keylock hobtid="72057599261540352" dbid="8" objectname="CMS.dbo.TABLE2" indexname="IX_TABLE2_ON_ID"
id="lock42febd80" mode="X" associatedObjectId="72057599261540352"> <owner-list> <owner id="process387bab0" mode="X"/> </owner-list>
<waiter-list> <waiter id="process8588388" mode="RangeS-S" requestType="wait"/> </waiter-list> </keylock> </resource-list> </deadlock>
</deadlock-list> </Column>