Skip to content

Commit fb1953e

Browse files
authored
Merge pull request #3783 from iaint-at-scc/AGBehind
sp_Blitz - Use Last Hardened Time for AG Behind Check if Last Commit Time is NULL
2 parents 2541c99 + 1441f74 commit fb1953e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

sp_Blitz.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6802,8 +6802,8 @@ IF @ProductVersionMajor >= 10
68026802
'https://www.BrentOzar.com/go/ag' AS URL,
68036803
ag.name + N' AG replica server ' +
68046804
ar.replica_server_name + N' is ' +
6805-
CASE WHEN DATEDIFF(SECOND, drs.last_commit_time, ps.last_commit_time) < 200 THEN (CAST(DATEDIFF(SECOND, drs.last_commit_time, ps.last_commit_time) AS NVARCHAR(10)) + N' seconds ')
6806-
ELSE (CAST(DATEDIFF(MINUTE, drs.last_commit_time, ps.last_commit_time) AS NVARCHAR(10)) + N' minutes ') END
6805+
CASE WHEN DATEDIFF(SECOND, ISNULL (drs.last_commit_time, drs.Last_hardened_time), ps.last_commit_time) < 200 THEN (CAST(DATEDIFF(SECOND, drs.last_commit_time, ps.last_commit_time) AS NVARCHAR(10)) + N' seconds ')
6806+
ELSE (CAST(DATEDIFF(MINUTE, ISNULL (drs.last_commit_time, drs.Last_hardened_time), ps.last_commit_time) AS NVARCHAR(10)) + N' minutes ') END
68076807
+ N' behind the primary.'
68086808
AS details
68096809
FROM sys.dm_hadr_database_replica_states AS drs
@@ -6814,7 +6814,7 @@ IF @ProductVersionMajor >= 10
68146814
AND drs.database_id = ps.database_id
68156815
AND ps.is_local = 1 /* Primary */
68166816
WHERE drs.is_local = 0 /* Secondary */
6817-
AND DATEDIFF(SECOND, drs.last_commit_time, ps.last_commit_time) > 60;
6817+
AND DATEDIFF(SECOND,ISNULL (drs.last_commit_time, drs.Last_hardened_time), ps.last_commit_time) > 60
68186818
END;
68196819

68206820

0 commit comments

Comments
 (0)