Deadlock because of same process

  • Dear All,

    Below the deadlock info from our system. Seems like the same process is causing the issue. how can i resolve this?

    <deadlock>

    <victim-list>

    <victimProcess id="process8ab67c108" />

    </victim-list>

    <process-list>

    <process id="process8ab67c108" taskpriority="0" logused="1100" waitresource="RID: 6:1:1121589:0" waittime="200" ownerId="432047033" transactionname="user_transaction" lasttranstarted="2016-09-26T22:30:56.467" XDES="0xe980fc3b0" lockMode="S" schedulerid="9" kpid="22992" status="suspended" spid="186" sbid="2" ecid="0" priority="0" trancount="1" lastbatchstarted="2016-09-26T22:30:56.470" lastbatchcompleted="2016-09-26T22:30:55.903" lastattention="1900-01-01T00:00:00.903" clientapp="EntityFramework" hostname="KPDCSVBT001-SYS" hostpid="22268" loginname="PRDPCSDO" isolationlevel="read committed (2)" xactid="432047033" currentdb="6" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">

    <executionStack>

    <frame procname="adhoc" line="3" stmtstart="278" stmtend="448" sqlhandle="0x020000001cf5f1040b2725a88d067cff527644f34e7fe68c0000000000000000000000000000000000000000">

    unknown </frame>

    <frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">

    unknown </frame>

    </executionStack>

    <inputbuf>

    (@0 varchar(20),@1 varchar(max) ,@2 datetime2(7))INSERT [dbo].[MessageLog]([AppModule], [ErrorMessage], [CreatedDate])

    VALUES (@0, @1, @2)

    SELECT [oid]

    FROM [dbo].[MessageLog]

    WHERE @@ROWCOUNT > 0 AND [oid] = scope_identity() </inputbuf>

    </process>

    <process id="processd40e91088" taskpriority="0" logused="1100" waitresource="RID: 6:1:1121588:0" waittime="200" ownerId="432047043" transactionname="user_transaction" lasttranstarted="2016-09-26T22:30:56.523" XDES="0xdcfad5670" lockMode="S" schedulerid="11" kpid="52400" status="suspended" spid="200" sbid="2" ecid="0" priority="0" trancount="1" lastbatchstarted="2016-09-26T22:30:56.520" lastbatchcompleted="2016-09-26T22:30:56.413" lastattention="1900-01-01T00:00:00.413" clientapp="EntityFramework" hostname="KPDCSVBT001-SYS" hostpid="22268" loginname="PRDPCSDO" isolationlevel="read committed (2)" xactid="432047043" currentdb="6" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">

    <executionStack>

    <frame procname="adhoc" line="3" stmtstart="278" stmtend="448" sqlhandle="0x020000001cf5f1040b2725a88d067cff527644f34e7fe68c0000000000000000000000000000000000000000">

    unknown </frame>

    <frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">

    unknown </frame>

    </executionStack>

    <inputbuf>

    (@0 varchar(20),@1 varchar(max) ,@2 datetime2(7))INSERT [dbo].[MessageLog]([AppModule], [ErrorMessage], [CreatedDate])

    VALUES (@0, @1, @2)

    SELECT [oid]

    FROM [dbo].[MessageLog]

    WHERE @@ROWCOUNT > 0 AND [oid] = scope_identity() </inputbuf>

    </process>

    </process-list>

    <resource-list>

    <ridlock fileid="1" pageid="1121589" dbid="6" objectname="Test.[dbo].MessageLog" id="locke39b6e100" mode="X" associatedObjectId="72057594077249536">

    <owner-list>

    <owner id="processd40e91088" mode="X" />

    </owner-list>

    <waiter-list>

    <waiter id="process8ab67c108" mode="S" requestType="wait" />

    </waiter-list>

    </ridlock>

    <ridlock fileid="1" pageid="1121588" dbid="6" objectname="Test.[dbo].MessageLog" id="locke4b620380" mode="X" associatedObjectId="72057594077249536">

    <owner-list>

    <owner id="process8ab67c108" mode="X" />

    </owner-list>

    <waiter-list>

    <waiter id="processd40e91088" mode="S" requestType="wait" />

    </waiter-list>

    </ridlock>

    </resource-list>

    </deadlock>

  • No, a session cannot deadlock itself and there are two different spids in there, spid="186" & spid="200".

    😎

    On the other hand, this looks like a multi threaded Entity Framework application where one thread is deadlocking another. I can easily see few of these

    (@0 varchar(20),@1 varchar(max) ,@2 datetime2(7))INSERT [dbo].[MessageLog]([AppModule], [ErrorMessage], [CreatedDate])

    VALUES (@0, @1, @2)

    SELECT [oid]

    FROM [dbo].[MessageLog]

    WHERE @@ROWCOUNT > 0 AND [oid] = scope_identity() running at the same time causing a little congestion.

  • Eirikur Eiriksson (9/26/2016)


    No, a session cannot deadlock itself and there are two different spids in there, spid="186" & spid="200".

    😎

    On the other hand, this looks like a multi threaded Entity Framework application where one thread is deadlocking another. I can easily see few of these

    (@0 varchar(20),@1 varchar(max) ,@2 datetime2(7))INSERT [dbo].[MessageLog]([AppModule], [ErrorMessage], [CreatedDate])

    VALUES (@0, @1, @2)

    SELECT [oid]

    FROM [dbo].[MessageLog]

    WHERE @@ROWCOUNT > 0 AND [oid] = scope_identity() running at the same time causing a little congestion.

    Thanks Eirikur. You are right these are from Entity Framework application. I have created index on table MessageLog on column Oid and i think it resolved the issue. Do you think still there can be chances.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply