SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Deadlock on the same resource with incompatible locks


Deadlock on the same resource with incompatible locks

Author
Message
ioani
ioani
SSC-Addicted
SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)

Group: General Forum Members
Points: 419 Visits: 414
Hi,

I have a table named ClientContext that has only the clustered index.
I have a procedure sp1 that call other two procedures: sp2 and then sp3.
The procedure sp2 inserts some data in the table and sp3 update data in the table.


CREATE PROCEDURE sp1
AS
BEGIN
EXEC sp2;
EXEC sp3
END




CREATE PROCEDURE sp2
AS
BEGIN
INSERT INTO ClientContext.....
END




CREATE PROCEDURE sp3
AS
BEGIN
UPDATE ClientContext....
END



The procedure sp1 is called from application. I have an deadlock on UPDATE in sp3 procedure.
I get the graph of deadlock with SQL Profiler (see the attachement Deadlock.png image file).
I get the locks after deadlock ocured from sys.dm_tran_locks system view (see attachement dm_tran_lock.png)

It seems from the graph that process 55 has Update (U) lock on the index and process 64 has exclusive lock (X) on the same index.
But U and X locks are incompatible locks.
How can two processes put incompatible locks on the same resource?
Could anybody explain me this?
Attachments
Deadlock.PNG (10 views, 77.00 KB)
dm_tran_locks.PNG (13 views, 30.00 KB)
GilaMonster
GilaMonster
SSC Guru
SSC Guru (237K reputation)SSC Guru (237K reputation)SSC Guru (237K reputation)SSC Guru (237K reputation)SSC Guru (237K reputation)SSC Guru (237K reputation)SSC Guru (237K reputation)SSC Guru (237K reputation)

Group: General Forum Members
Points: 237503 Visits: 46378
The X and U locks are key locks, not object locks. Each one is locking a different row in the index.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


ioani
ioani
SSC-Addicted
SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)SSC-Addicted (419 reputation)

Group: General Forum Members
Points: 419 Visits: 414
Thanks
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search