All,
I am running into a deadlock in SQL Server 2008. Using a profiler I was able to determine that the deadlock happens as I am trying to select and update row(S) in table in 2 different sessions.
The select query from the profiler is shown below
select
nodeinstan0_.id as id35_,
nodeinstan0_.BPMN_ELEMENT_ID as BPMN2_35_,
nodeinstan0_.END_DATE as END3_35_,
nodeinstan0_.NODE_ID as NODE4_35_,
nodeinstan0_.NODE_INSTANCE_ID as NODE5_35_,
nodeinstan0_.NODE_NAME as NODE6_35_,
nodeinstan0_.PROCESS_INSTANCE_ID as PROCESS7_35_,
nodeinstan0_.START_DATE as START8_35_ from
NODE_INSTANCE_LOG nodeinstan0_ where
nodeinstan0_.NODE_INSTANCE_ID=@P0 and
nodeinstan0_.PROCESS_INSTANCE_ID=@P1 and(nodeinstan0_.END_DATE isnull)
My SQL Scripts for creating the table and index is show below
CREATETABLE[dbo].[NODE_INSTANCE_LOG]([id][numeric](19,0)IDENTITY(1,1)NOTNULL,[BPMN_ELEMENT_ID][varchar](255)NULL,[END_DATE][datetime]NULL,[NODE_ID][varchar](255)NOTNULL,[NODE_INSTANCE_ID][varchar](255)NOTNULL,[NODE_NAME][varchar](2000)NULL,[PROCESS_INSTANCE_ID][numeric](19,0)NOTNULL,[START_DATE][datetime]NULL,PRIMARYKEYCLUSTERED[id]ASC)WITH(PAD_INDEX =OFF, STATISTICS_NORECOMPUTE =OFF,
IGNORE_DUP_KEY =OFF, ALLOW_ROW_LOCKS =ON,
ALLOW_PAGE_LOCKS =ON)ON[PRIMARY])ON[PRIMARY]
GOCREATENONCLUSTEREDINDEX IX_NODE_INSTANCE_LOG_Index1ON NODE_INSTANCE_LOG(NODE_INSTANCE_ID, PROCESS_INSTANCE_ID, END_DATE)
INCLUDE ( ID, BPMN_ELEMENT_ID, NODE_ID, NODE_NAME, START_DATE);
As I understood from number of other forums and blogs - I have included the columns under the where clause in the "COVERING index" and the rest of the columns from the select query under non clustered Index. But I am still facing a deadlock.
Would appreciate if some once can point me in the right direction.
regards D