Re: Deadlocks on Update
From: Nikhil Patel (nikhil0100_at_aol.com)
Date: 05/26/04
- Next message: Adam Machanic: "Re: DELETE Trigger that will only allow cascading deletes"
- Previous message: Hari: "Re: DBCC PERFMON"
- In reply to: Vidya: "Deadlocks on Update"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 26 May 2004 11:38:42 -0400
Hi,
Try changing the following line
Inner Join ShopDB.dbo.AttributeValues aval On
To
Inner Join ShopDB.dbo.AttributeValues aval WITH(ROWLOCK) On
If you have other queries, you may have to change them. Use WITH(NOLOCK)
hint if you are not updating the table. If you are updating the table use
WITH(ROWLOCK) hint. This way your update query will lock only one row at any
time instead of locking the entire table.
"Vidya" <anonymous@discussions.microsoft.com> wrote in message
news:CDDFF1C9-BE9F-4A5F-9E97-1FC8B547612D@microsoft.com...
> I have a multithreaded service executing a stored procedure which updates
the table shown below. SQL Server repeatedly runs into deadlocks on the
Update statement given below. I have included the trace error log messages
as well.
>
> Is the Inner Join in the Update query causing locking issues? Any insight
on how to mitigate this deadlock issue would be very helpful.
>
> Thanks in advance for your help.
>
> Thanks,
> Vidya
>
> AttributeValues table -
> Name Type Length Nullable
> avalId int 4 No
> aclaID int 4 No
> avalInt int 4 Yes
> avalDecimal decimal 9,3 Yes
> avalMin decimal 9,3 Yes
> avalMax decimal 9,3 yes
> avalString nvarchar 50 Yes
>
> Update aval
> Set
> aval.avalString = tmpAtt.stringValue
> From @tmpAttributes tmpAtt
> Inner Join ShopDB.dbo.AttributeValues aval On
> (aval.aclaId =
tmpAtt.aclaId
> And
Coalesce(aval.avalInt,-999) = Coalesce(tmpAtt.intValue,-99)
> And
Coalesce(aval.avalDecimal,-99999.99) =
Coalesce(tmpAtt.decimalValue,-99999.99)
> And tmpAtt.aclaType In
('I','D')--update string value only for Int and Decimal value types
> And (aval.avalString
<> tmpAtt.stringValue)
> )
>
> The following is the information from SQL Server Error Log -
>
> Date Source Message
> 2004-05-24 19:22:37.30 spid4 ResType:LockOwner Stype:'OR' Mode: U
SPID:68 ECID:0 Ec:(0x1cb2f5a0) Value:0x194
> 2004-05-24 19:22:37.30 spid4 Victim Resource Owner:
> 2004-05-24 19:22:37.30 spid4 ResType:LockOwner Stype:'OR' Mode: U
SPID:68 ECID:0 Ec:(0x1cb2f5a0) Value:0x194
> 2004-05-24 19:22:37.30 spid4 Requested By:
> 2004-05-24 19:22:37.30 spid4 Input Buf: Language Event: exec
ShopDB.dbo.usp_GetIdDataForIndexer @kwrdList=N
> 2004-05-24 19:22:37.30 spid4 SPID: 66 ECID: 0 Statement Type:
UPDATE Line #: 89
> 2004-05-24 19:22:37.30 spid4 Owner:0x1942ee80 Mode: U
Flg:0x0 Ref:0 Life:00000001 SPID:66 ECID:0
> 2004-05-24 19:22:37.30 spid4 Grant List::
> 2004-05-24 19:22:37.30 spid4 KEY: 17:715149593:7 (5700dbe939b3)
CleanCnt:1 Mode: U Flags: 0x0
> 2004-05-24 19:22:37.30 spid4 Node:2
> 2004-05-24 19:22:37.30 spid4
> 2004-05-24 19:22:37.30 spid4 ResType:LockOwner Stype:'OR' Mode: U
SPID:66 ECID:0 Ec:(0x1bf615a0) Value:0x194
> 2004-05-24 19:22:37.30 spid4 Requested By:
> 2004-05-24 19:22:37.30 spid4 Input Buf: Language Event: exec
ShopDB.dbo.usp_GetIdDataForIndexer @kwrdList=N
> 2004-05-24 19:22:37.30 spid4 SPID: 68 ECID: 0 Statement Type:
UPDATE Line #: 89
> 2004-05-24 19:22:37.30 spid4 Owner:0x194356a0 Mode: U
Flg:0x0 Ref:0 Life:00000001 SPID:68 ECID:0
> 2004-05-24 19:22:37.30 spid4 Grant List::
> 2004-05-24 19:22:37.30 spid4 KEY: 17:715149593:7 (07008281220c)
CleanCnt:1 Mode: U Flags: 0x0
> 2004-05-24 19:22:37.30 spid4 Node:1
> 2004-05-24 19:22:37.30 spid4
> 2004-05-24 19:22:37.30 spid4 Wait-for graph
>
>
- Next message: Adam Machanic: "Re: DELETE Trigger that will only allow cascading deletes"
- Previous message: Hari: "Re: DBCC PERFMON"
- In reply to: Vidya: "Deadlocks on Update"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|