Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

SQL Server 2012 Std - Merge Replication - Deadlocks

$
0
0

Hi,

I have a merge replication between 2 SQL serve r2012 std sp2. The merge agent keeps getting deadlocked and killed. It seems that procedures fired by triggers and sp_msmakegeneration are locking each other out. What can be done to fix this ?

An example:

Deadlock graph					<deadlock-list><deadlock victim="process1f0284cf8"><process-list><process id="process1f0284cf8" taskpriority="5" logused="368936" waitresource="KEY: 15:72057594074824704 (8b2843006660)" waittime="885" ownerId="24546267" transactionname="user_transaction" lasttranstarted="2015-08-11T12:24:18.290" XDES="0x1fd2a23a8" lockMode="U" schedulerid="4" kpid="4616" status="suspended" spid="123" sbid="0" ecid="0" priority="-5" trancount="2" lastbatchstarted="2015-08-11T12:24:16.763" lastbatchcompleted="2015-08-11T12:24:16.757" lastattention="1900-01-01T00:00:00.757" clientapp="Replication Merge Agent" hostname="DT-SVT-SQL-02" hostpid="5092" loginname="INSTREAM\sqlrepltest" isolationlevel="read committed (2)" xactid="24546267" currentdb="15" lockTimeout="4294967295" clientoption1="673384544" clientoption2="128024"><executionStack><frame procname="mssqlsystemresource.sys.sp_MSmakegeneration" line="337" stmtstart="29568" stmtend="29880" sqlhandle="0x0300ff7fa885d0f933812f012ba3000001000000000000000000000000000000000000000000000000000000">
update dbo.MSmerge_contents with (rowlock) set generation = @target_gen
                where generation = @gen and tablenick = @art_nick     </frame></executionStack><inputbuf>
Proc [Database Id = 32767 Object Id = -103774808]    </inputbuf></process><process id="process279bb9c38" taskpriority="0" logused="11788" waitresource="KEY: 15:72057594074890240 (4d59435678e9)" waittime="2910" ownerId="24547029" transactionname="tx_tran" lasttranstarted="2015-08-11T12:24:18.703" XDES="0x1f7e176a8" lockMode="X" schedulerid="4" kpid="3600" status="suspended" spid="122" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2015-08-11T12:24:18.630" lastbatchcompleted="2015-08-11T12:24:18.630" lastattention="1900-01-01T00:00:00.630" clientapp=".Net SqlClient Data Provider" hostname="DT-SVT-TRA-02" hostpid="50156" loginname="INSTREAM\svctestprovregi" isolationlevel="read committed (2)" xactid="24547029" currentdb="15" lockTimeout="4294967295" clientoption1="673316896" clientoption2="128024"><executionStack><frame procname="iTRANS.dbo.MSmerge_upd_A8EC7E7BF7E44623A7AF6C3061D10DB1" line="65" stmtstart="4694" stmtend="5756" sqlhandle="0x03000f00362460098f0ebb00f1a4000000000000000000000000000000000000000000000000000000000000">
update [dbo].[MSmerge_ctsv_A8EC7E7BF7E44623A7AF6C3061D10DB1] with (rowlock)
			set lineage = { fn UPDATELINEAGE(lineage, @replnick, @oldmaxversion+1) },
				generation = @newgen,
				partchangegen = case when (@partchange = 1 or @joinchange = 1) then @newgen else partchangegen end,

					colv1 = NULL
			FROM inserted as I JOIN [dbo].[MSmerge_ctsv_A8EC7E7BF7E44623A7AF6C3061D10DB1] as V with (rowlock)
			ON (I.rowguidcol=V.rowguid)
			and V.tablenick = @tablenick
			option (force order, loop join)     </frame><frame procname="iTRANS.dbo.s_msg_conv_process_host_tx" line="138" stmtstart="14682" stmtend="16412" sqlhandle="0x03000f0096d4167fcc43a100f1a4000001000000000000000000000000000000000000000000000000000000">
update msg_conversation set
			host_tx_msg_id = @tx_msg_id,
			host_tx_style = @tx_tx_style,
			host_tx_version = @tx_tx_version,
			host_tx_type = @tx_tx_type,
			host_tx_msg_status = 4,						--msg_status 4 = Acknowledged
			host_tx_dt = getUTCDate(),
			host_tx_msg_count = isnull(host_tx_msg_count, 0) + 1,
			host_tx_reference = @host_tx_reference,
			host_router_ack_msg_id = @ack_msg_id,
			host_router_ack_msg_count = isnull(host_router_ack_msg_count, 0) + 1,
			host_router_ack_dt = getUTCDate(),
			host_router_client_tx_msg_id = @tx_msg_id,			-- NOTE!!! only diff from update above, is this line.
			host_router_client_tx_dt = getUTCDate(),
			client_outcome_id = @client_outcome_id,
			host_outcome_id = @host_outcome_id,
			last_event_id= @last_event_id,
			last_event_dt = getUTCDate()
			where
			msg_conv_id = @msg_conv_id     </frame></executionStack><inputbuf>
Proc [Database Id = 15 Object Id = 2132202646]    </inputbuf></process></process-list><resource-list><keylock hobtid="72057594074824704" dbid="15" objectname="iTRANS.dbo.MSmerge_contents" indexname="uc1SycContents" id="lock23cd21900" mode="X" associatedObjectId="72057594074824704"><owner-list><owner id="process279bb9c38" mode="X"/></owner-list><waiter-list><waiter id="process1f0284cf8" mode="U" requestType="wait"/></waiter-list></keylock><keylock hobtid="72057594074890240" dbid="15" objectname="iTRANS.dbo.MSmerge_contents" indexname="nc2MSmerge_contents" id="lock2139a4a80" mode="U" associatedObjectId="72057594074890240"><owner-list><owner id="process1f0284cf8" mode="U"/></owner-list><waiter-list><waiter id="process279bb9c38" mode="X" requestType="wait"/></waiter-list></keylock></resource-list></deadlock></deadlock-list>
					sa			25	2015-08-11 12:24:21.733

Regards,

Olivier


Viewing all articles
Browse latest Browse all 4054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>