Pls. we've been getting A LOT of locks on a production database that's recently witnessed substantially increased traffic. We are using IdeaBlade for most of the data access.
I got the following trace using Sql Profiler:
deadlock victim="process84af28"
resource-list
keylock hobtid="72057594096451584" dbid="6" objectname="cpc_db.dbo.Prefix_ChildTableName" indexname="PK_Prefix_ChildTableName" id="lock45982ac0" mode="X" associatedObjectId="72057594096451584"
owner-list
owner id="processb852e8" mode="X"
owner-list
waiter-list
waiter id="process84af28" mode="S" requestType="wait"
waiter id="processb855b8" mode="RangeS-U" requestType="wait"
waiter-list
keylock
keylock hobtid="72057594096451584" dbid="6" objectname="cpc_db.dbo.Prefix_ChildTableName" indexname="PK_Prefix_ChildTableName" id="lock513c3bc0" mode="RangeS-U" associatedObjectId="72057594096451584"
owner-list
owner id="processb855b8" mode="RangeS-U"
owner-list
waiter-list
waiter id="processb852e8" mode="RangeS-U" requestType="wait"
waiter-list
keylock
resource-list
deadlock
Ideas anyone?
I'm not a DBA but this trace seems to indicate that:
A process with an exclusive lock X on a row in the Child Table is attempting to acquire a Select-Update lock on the same resource (doesn't seem to make sense)
Another process with a Select-Update lock is still trying to acquire a Select-Update lock
Clarifications anyone?
How can we minimize or eliminate the deadlocks?
Range locks? Stop using high transaction isolation levels. Stick to read commited. If you use CLR TransactionScope object, make them use the Read Commited isolation (by default they use Seralizable, yuck). Try turning on read committed snapshot isolation on the database. See Using Snapshot Isolation.