This instance hosts the SharePoint 2007 databases (SP). We have been experiencing numerous SELECT/INSERT deadlocks against one heavily utilized table within SP content database. I have narrowed down the resources involved, both processes are requiring locks on the non-clustered index.
The INSERT needs an IX lock on the SELECT resource and the SELECT needs a S lock on the INSERT resource. The deadlock graph depicts and three resources, 1.) two from the SELECT (producer/consumer parallel threads), and 2.) the INSERT.
I have attached the deadlock graph for your review. Because this is Microsoft code and table structures we cannot make any changes.
However, I have read, on the MSFT SP site, that they recommend setting MAXDOP Instance level configuration option to 1. Since this instance is shared amongst many other databases/applications this setting cannot be disabled.
Therefore, I decided to try and prevent these SELECT statements from going parallel. I know this is not a solution but more a temporary modification to help with troubleshooting. Therfore, I increased the “Cost Threshold for Parallelism” from our standard 25 to 40 upon doing so, even though the workload has not changed (SELECT/INSERT occurring frequently) the deadlocks have disappeared. My question is why?
SPID 356 INSERT has an IX lock on a page belonging to the non-clustered index
SPID 690 SELECT Execution ID 0 has S lock on a page belonging to the same non clustered index
Now
SPID 356 wants an IX lock on SPID 690 resource but cannot ontain it because SPID 356 is being blocked by SPID 690 Execution ID 0 S lock
SPID 690 Execution ID 1 wants a S lock on SPID 356 resource but cannot obtain it because SPID 690 Execution ID 1 is being blocked by SPID 356 and now we have our deadlock.
Execution Plan can be found on my SkyDrive
Full Deadlock Details can be found here
If someone can help me understand why I would really appreciate it.
EventReceivers Table.
Id uniqueidentifier no 16
Name nvarchar no 512
SiteId uniqueidentifier no 16
WebId uniqueidentifier no 16
HostId uniqueidentifier no 16
HostType int no 4
ItemId int no 4
DirName nvarchar no 512
LeafName nvarchar no 256
Type int no 4
SequenceNumber int no 4
Assembly nvarchar no 512
Class nvarchar no 512
Data nvarchar no 512
Filter nvarchar no 512
SourceId tContentTypeId no 512
SourceType int no 4
Credential int no 4
ContextType varbinary no 16
ContextEventType varbinary no 16
ContextId varbinary no 16
ContextObjectId varbinary no 16
ContextCollectionId varbinary no 16
index_name index_description index_keys
EventReceivers_ByContextCollectionId nonclustered located on PRIMARY SiteId, ContextCollectionId
EventReceivers_ByContextObjectId nonclustered located on PRIMARY SiteId, ContextObjectId
EventReceivers_ById nonclustered, unique located on PRIMARY SiteId, Id
EventReceivers_ByTarget clustered, unique located on PRIMARY SiteId, WebId, HostId, HostType, Type, ContextCollectionId, ContextObjectId, ContextId, ContextType, ContextEventType, SequenceNumber, Assembly, Class
EventReceivers_IdUnique nonclustered, unique, unique key located on PRIMARY Id
proc_InsertEventReceiver
andproc_InsertContextEventReceiver
do that we can't see in the XDL? Also to reduce parallelism why not just impact these statement directly (using MAXDOP 1) instead of futzing with server-wide settings? – Aaron Bertrand Nov 26 '12 at 23:48