Transaction Log Backup on the secondary Replica RRS feed

  • General discussion

  • Hi Guys,

    I have a situation that I've been trying to figure it out for last couple of days now.

    I do have AlwaysOn setup with 2 Secondary Replica. 

    I am using Ola Haegreen scripts to automate my backups jobs.

    I have full bak once a every day at 12am

    And Tlog bak hourly.

    on one of my secondary Tlog backup are taking too long to finish to the point where i am cancelling it. the job is not finishing to run. but on other secondary replica it only takes 15 to 20 seconds to complete.

    what might be the problem?

    I have tried to change, re-create the job but it's the same situation. 

    can you guys help?

    Thank you,


    Monday, July 8, 2019 4:09 PM

All replies

  • Have you checked what the backup session is waiting on? Are both secondaries synchronized with the primary? 

    Is there a difference in the number of concurrent users/processes connected to the slower secondary replica v/s the faster secondary? 

    Are the two secondaries in the same Data Center as primary? Maybe there's I/O latency.

    I'd start by looking at the waits (for the t-log backup session) and dig further. 

    Please remember to click "Mark as Answer" if my response answered your question or click "Vote as helpful" if it helped you in any way.

    Monday, July 8, 2019 5:44 PM
  • Hello Mohsin,

    Thank you for getting back to me, 

    the user are connecting to the faster secondary.

    on the two secondary, the slower one is not in the same data center with Primary. Primary is in canada and the slower socondary is in the USA.

    I will now check the wait time as you recommended.

    Thank you again,

    Monday, July 8, 2019 5:50 PM
  • From what I can see i do have a Cumulative wait time of 88403 Network I/O and 

    367166 Backup

    Other 693791

    Monday, July 8, 2019 5:54 PM
  • what is the version of your SQL server? if it's 2016+ you can monitor session-level waits with sys.dm_exec_session_wait_stats. Anyway, are you sure it was simply "Backup" that showed up as a wait type and not "BACKUPIO" or something? Also, is the faster secondary in USA as well?

    You can also monitor the waits using Dmitri's script below. 

    /*                         SQL Server Internals v3                          */
    /*                           Training Materials                             */
    /*                                                                          */
    /*                  Written by Dmitri V. Korotkevitch                       */
    /*                                       */
    /*                                           */
    /*                         Diagnostics Scripts                              */
    /*                           Wait Statistics                                */
    /*** Clearing Waits ***/
    -- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR) 
    /*** Checking Top Waits in the System ***/
    ;with Waits
    		wait_type, wait_time_ms, waiting_tasks_count,signal_wait_time_ms
    		,wait_time_ms - signal_wait_time_ms as resource_wait_time_ms
    		,100. * wait_time_ms / SUM(wait_time_ms) over() as Pct
    		,row_number() over(order by wait_time_ms desc) AS RowNum
    	from sys.dm_os_wait_stats with (nolock)
    		wait_type not in /* Filtering out non-essential system waits */
    	--and wait_time_ms > 0
    	w1.wait_type as [Wait Type]
    	,w1.waiting_tasks_count as [Wait Count]
    	,convert(decimal(12,3), w1.wait_time_ms / 1000.0) as [Wait Time]
    	,convert(decimal(12,1), w1.wait_time_ms / w1.waiting_tasks_count) as [Avg Wait Time]
    	,convert(decimal(12,3), w1.signal_wait_time_ms / 1000.0) as [Signal Wait Time]
    	,convert(decimal(12,1), w1.signal_wait_time_ms / w1.waiting_tasks_count) as [Avg Signal Wait Time]
    	,convert(decimal(12,3), w1.resource_wait_time_ms / 1000.0) as [Resource Wait Time]
    	,convert(decimal(12,1), w1.resource_wait_time_ms / w1.waiting_tasks_count) as [Avg Resource Wait Time]
    	,convert(decimal(6,3), w1.Pct) as [Percent]
    	,convert(decimal(6,3), w1.Pct + IsNull(w2.Pct,0)) as [Running Percent]
    	Waits w1 cross apply
    		select sum(w2.Pct) as Pct
    		from Waits w2
    		where w2.RowNum < w1.RowNum
    	) w2
    	w1.RowNum = 1 or w2.Pct <= 99
    order by
    option (recompile);
    /*** Comparing Signal and Resource Waits ***/
    	sum(signal_wait_time_ms) as [Signal Wait Time (ms)]
    	,convert(decimal(7,4), 100.0 * sum(signal_wait_time_ms) / 
    		sum (wait_time_ms)) as [% Signal waits]
    	,sum(wait_time_ms - signal_wait_time_ms) as [Resource Wait Time (ms)]
    	,convert(decimal(7,4), 100.0 * sum(wait_time_ms - signal_wait_time_ms) / 
    		sum (wait_time_ms)) as [% Resource waits]
    	sys.dm_os_wait_stats with (nolock)
    option (recompile);
    /*** List of currently waiting tasks ***/
    	sys.dm_os_waiting_tasks wt with (nolock)
    order by 
    	wt.wait_duration_ms desc
    option (recompile);
    -- SQL Server 2016+. Session-Level waits
    select * 
    from sys.dm_exec_session_wait_stats 
    where session_id = 147; 

    Please remember to click "Mark as Answer" if my response answered your question or click "Vote as helpful" if it helped you in any way.

    Monday, July 8, 2019 10:31 PM