Hi all, really hope you can help.
We've got a problem with conversion deadlocking going on within one environment (the same proc + trigger works in at least four other environments).
The stored proc in question inserts a row into a table (cmsreceipt) that has a trigger which updates another table (cmsreceiptarchive). To try and prevent deadlocks a select on the cmsreceiptarchive table with xlock, rowlock is done before the insert to get a lock on the table that the trigger updates. This works in four versions of the db but not in this one environment (sql 2005).
I'll copy the deadlock graph below but to me it seems as though we're getting table scans that are taking to long to complete on table CmsReceipt and this allows another SPID running the same proc to get a shared lock on the table too and then they both try and get IX locks once they're ready to do the update on CmsReceipt.
I've checked the indexes (a clustered index and two non-clustered) and they match the other databases that work fine so I don't know why we're getting table scans on this db but not in the others.
I've tried all sorts of hints (both in the main process and the trigger) but to no avail.
Help! Thanks in advance for any help.
<deadlock-list>
<deadlock victim="process76d5708">
<process-list>
<process id="process76d5708" taskpriority="0" logused="0" waitresource="OBJECT: 7:1550628567:0 " waittime="4776" ownerId="34034594" transactionguid="0x4e9e61bf45eed2429a05ad44fa09ec50" transactionname="user_transaction" lasttranstarted="2009-11-24T15:51:12.280" XDES="0x1e0ca5970" lockMode="IX" schedulerid="8" kpid="14340" status="suspended" spid="57" sbid="2" ecid="0" priority="0" trancount="3" lastbatchstarted="2009-11-24T15:51:17.513" lastbatchcompleted="2009-11-24T15:49:54.807" clientapp=".Net SqlClient Data Provider" hostname="XXX" hostpid="4804" loginname="XXXX" isolationlevel="serializable (4)" xactid="34034594" currentdb="1" lockTimeout="4294967295" clientoption1="673185824" clientoption2="128056">
<executionStack>
<frame procname="XXX.dbo.Main_InsertCmsReceipt" line="43" stmtstart="2388" stmtend="3096" sqlhandle="0x03000700d7b7b271d2daf900cb9c00000100000000000000">
insert into CmsReceipt with (updlock) (
CmsReceiptId,
ModifiedAt,
ModifiedBy,
CmsMessageId,
Status,
Details,
ReceiptTimestamp,
SenderName,
SenderId
)
values (
@New_CmsReceiptId,
@New_ModifiedAt,
@New_ModifiedBy,
@New_CmsMessageId,
@New_Status,
@New_Details,
@New_ReceiptTimestamp,
@New_SenderName,
@New_SenderId
) </frame>
</executionStack>
<inputbuf>
Proc [Database Id = 7 Object Id = 1907537879] </inputbuf>
</process>
<process id="process70a1dc8" taskpriority="0" logused="0" waitresource="OBJECT: 7:1550628567:0 " waittime="4498" ownerId="34034604" transactionguid="0x6719e8b21f633a48bf47c77a62f2af2c" transactionname="user_transaction" lasttranstarted="2009-11-24T15:51:12.483" XDES="0x1e1a77970" lockMode="IX" schedulerid="6" kpid="13632" status="suspended" spid="69" sbid="2" ecid="0" priority="0" trancount="3" lastbatchstarted="2009-11-24T15:51:17.780" lastbatchcompleted="2009-11-24T15:49:54.807" clientapp=".Net SqlClient Data Provider" hostname="XXXX" hostpid="4804" loginname="XXXXXX" isolationlevel="serializable (4)" xactid="34034604" currentdb="1" lockTimeout="4294967295" clientoption1="673185824" clientoption2="128056">
<executionStack>
<frame procname="XXX.dbo.Main_InsertCmsReceipt" line="43" stmtstart="2388" stmtend="3096" sqlhandle="0x03000700d7b7b271d2daf900cb9c00000100000000000000">
insert into CmsReceipt with (updlock) (
CmsReceiptId,
ModifiedAt,
ModifiedBy,
CmsMessageId,
Status,
Details,
ReceiptTimestamp,
SenderName,
SenderId
)
values (
@New_CmsReceiptId,
@New_ModifiedAt,
@New_ModifiedBy,
@New_CmsMessageId,
@New_Status,
@New_Details,
@New_ReceiptTimestamp,
@New_SenderName,
@New_SenderId
) </frame>
</executionStack>
<inputbuf>
Proc [Database Id = 7 Object Id = 1907537879] </inputbuf>
</process>
</process-list>
<resource-list>
<objectlock lockPartition="0" objid="1550628567" subresource="FULL" dbid="7" objectname="XXX.dbo.CmsReceipt" id="lock9c4eec80" mode="S" associatedObjectId="1550628567">
<owner-list>
<owner id="process70a1dc8" mode="S"/>
</owner-list>
<waiter-list>
<waiter id="process76d5708" mode="IX" requestType="convert"/>
</waiter-list>
</objectlock>
<objectlock lockPartition="0" objid="1550628567" subresource="FULL" dbid="7" objectname="XXX.dbo.CmsReceipt" id="lock9c4eec80" mode="S" associatedObjectId="1550628567">
<owner-list>
<owner id="process76d5708" mode="S"/>
</owner-list>
<waiter-list>
<waiter id="process70a1dc8" mode="IX" requestType="convert"/>
</waiter-list>
</objectlock>
PS Is there an easier way than 4 spaces at the start of each line to get the xml to show?