We faced deadlock while update and insert data on a table cause this issue. I got the below xml at SQL server extended events. Why insert and update leads to dead lock?
<?xml version="1.0"?>
-<deadlock>-<victim-list><victimProcess id="process3ff2b6558"/></victim-list>-<process-list>-<process id="process3ff2b6558" clientoption2="128056" clientoption1="671088672" lockTimeout="4294967295"
currentdb="9" xactid="23247310" isolationlevel="serializable (4)" loginname="sa" hostpid="6332" hostname="MSHEHR01" clientapp=".Net SqlClient Data Provider" lastattention="1900-01-01T00:00:00.820"
lastbatchcompleted="2013-08-26T10:53:34.820" lastbatchstarted="2013-08-26T10:53:34.820" trancount="2" priority="0" ecid="0" sbid="0" spid="61" status="suspended" kpid="5032"
schedulerid="2" lockMode="RangeS-U" XDES="0x4f65756a8" lasttranstarted="2013-08-26T10:53:34.820" transactionname="user_transaction" ownerId="23247310" waittime="4014" waitresource="KEY:
9:72057594290962432 (f3fd56449ff4)" logused="0" taskpriority="0">-<executionStack><frame sqlhandle="0x03000900967374004e70690023a2000001000000000000000000000000000000000000000000000000000000" stmtend="2810"
stmtstart="1408" line="33" procname="Mmt.Cyramed.WCF.ProductionDb.SalesPersonForms.PageLockStatusUpdate"> UPDATE SalesPersonForms.SalesPersonPages SET LockTypeId = 0, LockedByUserId = NULL, LockedOnDate = NULL, LockedOnMachine
= NULL WHERE LockedByUserId = @LockedByUserId AND LockTypeId=2 AND SalesPersonformid IN (SELECT SalesPersonFormId FROM SalesPersonforms.SalesPersonForms WITH (NOLOCK) WHERE SalesPersonid NOT IN (SELECT SalesPersonid FROM SalesPersonForms.SalesPersonForms WITH
(NOLOCK) WHERE SalesPersonFormId IN (SELECT SalesPersonFormId FROM SalesPersonForms.SalesPersonPages WITH (NOLOCK) WHERESalesPersonpageid=@SalesPersonPageId AND LockedByUserId = @LockedByUserId AND LockTypeId=2 AND sectionid IN (SELECT sectionid FROM SalesPersonForms.SalesPersonPages WITH (NOLOCK) WHERESalesPersonpageid=@SalesPersonPageId)))) </frame></executionStack><inputbuf> Proc [Database Id = 9 Object Id = 7631766] </inputbuf></process>-<process id="process3c7cc0cf8"
clientoption2="128056" clientoption1="673185824" lockTimeout="4294967295" currentdb="9" xactid="23247133" isolationlevel="serializable (4)" loginname="sa" hostpid="6332" hostname="MSHEHR01"
clientapp=".Net SqlClient Data Provider" lastattention="1900-01-01T00:00:00.847" lastbatchcompleted="2013-08-26T10:53:34.847" lastbatchstarted="2013-08-26T10:53:34.850" trancount="3" priority="0"
ecid="0" sbid="0" spid="53" status="suspended" kpid="2700" schedulerid="4" lockMode="RangeI-N" XDES="0x4f661cd28" lasttranstarted="2013-08-26T10:53:34.733" transactionname="user_transaction"
ownerId="23247133" waittime="3993" waitresource="KEY: 9:72057594290962432 (cdeb729cc339)" logused="104708" taskpriority="0">-<executionStack><frame sqlhandle="0x03000900cf976801fc87690023a2000001000000000000000000000000000000000000000000000000000000"
stmtend="8516" stmtstart="4512" line="61" procname="Mmt.Cyramed.WCF.ProductionDb.dbo.SalesPersonPagesInsert"> INSERT INTO SalesPersonForms.SalesPersonPages ( SalesPersonPageId , SalesPersonFormId , MasterPageId ,
SectionId , ParentShelfId , EncounterId , FormName , PageName , PageDescription , Position , FileTypeId , DocumentTypeId , Location , LockTypeId , PageVersion , LastModifiedDateTime , CreatedBy , CreatedOn , LastModifiedBy , GrammarText , IsFromExitWriter
, InkValue , HighLightValue , AnnotationValue , SummaryList , HasGrammarTextUpdated ) OUTPUT INSERTED.SalesPersonPageId INTO @outputTb </frame></executionStack><inputbuf> Proc [Database Id = 9 Object Id = 23631823] </inputbuf></process></process-list>-<resource-list>-<keylock
id="lock3fba69800" associatedObjectId="72057594290962432" mode="X" indexname="PK_SalesPersonPages" objectname="Mmt.Cyramed.WCF.ProductionDb.SalesPersonForms.SalesPersonPages" dbid="9" hobtid="72057594290962432">-<owner-list><owner
id="process3c7cc0cf8" mode="X"/></owner-list>-<waiter-list><waiter id="process3ff2b6558" mode="RangeS-U" requestType="wait"/></waiter-list></keylock>-<keylock id="lock3f9708080"
associatedObjectId="72057594290962432" mode="RangeS-U" indexname="PK_SalesPersonPages" objectname="Mmt.Cyramed.WCF.ProductionDb.SalesPersonForms.SalesPersonPages" dbid="9" hobtid="72057594290962432">-<owner-list><owner
id="process3ff2b6558" mode="RangeS-U"/></owner-list>-<waiter-list><waiter id="process3c7cc0cf8" mode="RangeI-N" requestType="wait"/></waiter-list></keylock></resource-list></deadlock>
Developer