3737SET NOCOUNT ON;
3838SET STATISTICS XML OFF;
3939
40- SELECT @Version = '8.20 ', @VersionDate = '20240522 ';
40+ SELECT @Version = '8.21 ', @VersionDate = '20240701 ';
4141
4242IF(@VersionCheckMode = 1)
4343BEGIN
@@ -1172,7 +1172,7 @@ SET NOCOUNT ON;
11721172SET STATISTICS XML OFF;
11731173SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
11741174
1175- SELECT @Version = '8.20 ', @VersionDate = '20240522 ';
1175+ SELECT @Version = '8.21 ', @VersionDate = '20240701 ';
11761176SET @OutputType = UPPER(@OutputType);
11771177
11781178IF(@VersionCheckMode = 1)
@@ -8545,7 +8545,7 @@ SET NOCOUNT ON;
85458545SET STATISTICS XML OFF;
85468546SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
85478547
8548- SELECT @Version = '8.20 ', @VersionDate = '20240522 ';
8548+ SELECT @Version = '8.21 ', @VersionDate = '20240701 ';
85498549
85508550IF(@VersionCheckMode = 1)
85518551BEGIN
@@ -13554,7 +13554,7 @@ SET NOCOUNT ON;
1355413554SET STATISTICS XML OFF;
1355513555SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
1355613556
13557- SELECT @Version = '8.20 ', @VersionDate = '20240522 ';
13557+ SELECT @Version = '8.21 ', @VersionDate = '20240701 ';
1355813558SET @OutputType = UPPER(@OutputType);
1355913559
1356013560IF(@VersionCheckMode = 1)
@@ -20029,6 +20029,7 @@ ALTER PROCEDURE
2002920029 @EventSessionName sysname = N'system_health',
2003020030 @TargetSessionType sysname = NULL,
2003120031 @VictimsOnly bit = 0,
20032+ @DeadlockType nvarchar(20) = NULL,
2003220033 @Debug bit = 0,
2003320034 @Help bit = 0,
2003420035 @Version varchar(30) = NULL OUTPUT,
@@ -20047,7 +20048,7 @@ BEGIN
2004720048 SET XACT_ABORT OFF;
2004820049 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
2004920050
20050- SELECT @Version = '8.20 ', @VersionDate = '20240522 ';
20051+ SELECT @Version = '8.21 ', @VersionDate = '20240701 ';
2005120052
2005220053 IF @VersionCheckMode = 1
2005320054 BEGIN
@@ -20209,7 +20210,7 @@ BEGIN
2020920210 @StartDateOriginal datetime = @StartDate,
2021020211 @EndDateOriginal datetime = @EndDate,
2021120212 @StartDateUTC datetime,
20212- @EndDateUTC datetime;
20213+ @EndDateUTC datetime;;
2021320214
2021420215 /*Temporary objects used in the procedure*/
2021520216 DECLARE
@@ -20719,50 +20720,63 @@ BEGIN
2071920720 END CATCH;
2072020721 END;
2072120722
20723+ IF @DeadlockType IS NOT NULL
20724+ BEGIN
20725+ SELECT
20726+ @DeadlockType =
20727+ CASE
20728+ WHEN LOWER(@DeadlockType) LIKE 'regular%'
20729+ THEN N'Regular Deadlock'
20730+ WHEN LOWER(@DeadlockType) LIKE N'parallel%'
20731+ THEN N'Parallel Deadlock'
20732+ ELSE NULL
20733+ END;
20734+ END;
20735+
2072220736 /*If @TargetSessionType, we need to figure out if it's ring buffer or event file*/
2072320737 /*Azure has differently named views, so we need to separate. Thanks, Azure.*/
2072420738
20725- IF
20726- (
20727- @Azure = 0
20728- AND @TargetSessionType IS NULL
20729- )
20730- BEGIN
20731- RAISERROR('@TargetSessionType is NULL, assigning for non-Azure instance', 0, 1) WITH NOWAIT;
20739+ IF
20740+ (
20741+ @Azure = 0
20742+ AND @TargetSessionType IS NULL
20743+ )
20744+ BEGIN
20745+ RAISERROR('@TargetSessionType is NULL, assigning for non-Azure instance', 0, 1) WITH NOWAIT;
2073220746
20733- SELECT TOP (1)
20734- @TargetSessionType = t.target_name
20735- FROM sys.dm_xe_sessions AS s
20736- JOIN sys.dm_xe_session_targets AS t
20737- ON s.address = t.event_session_address
20738- WHERE s.name = @EventSessionName
20739- AND t.target_name IN (N'event_file', N'ring_buffer')
20740- ORDER BY t.target_name
20741- OPTION(RECOMPILE);
20747+ SELECT TOP (1)
20748+ @TargetSessionType = t.target_name
20749+ FROM sys.dm_xe_sessions AS s
20750+ JOIN sys.dm_xe_session_targets AS t
20751+ ON s.address = t.event_session_address
20752+ WHERE s.name = @EventSessionName
20753+ AND t.target_name IN (N'event_file', N'ring_buffer')
20754+ ORDER BY t.target_name
20755+ OPTION(RECOMPILE);
2074220756
20743- RAISERROR('@TargetSessionType assigned as %s for non-Azure', 0, 1, @TargetSessionType) WITH NOWAIT;
20744- END;
20757+ RAISERROR('@TargetSessionType assigned as %s for non-Azure', 0, 1, @TargetSessionType) WITH NOWAIT;
20758+ END;
2074520759
20746- IF
20747- (
20748- @Azure = 1
20749- AND @TargetSessionType IS NULL
20750- )
20751- BEGIN
20752- RAISERROR('@TargetSessionType is NULL, assigning for Azure instance', 0, 1) WITH NOWAIT;
20760+ IF
20761+ (
20762+ @Azure = 1
20763+ AND @TargetSessionType IS NULL
20764+ )
20765+ BEGIN
20766+ RAISERROR('@TargetSessionType is NULL, assigning for Azure instance', 0, 1) WITH NOWAIT;
2075320767
20754- SELECT TOP (1)
20755- @TargetSessionType = t.target_name
20756- FROM sys.dm_xe_database_sessions AS s
20757- JOIN sys.dm_xe_database_session_targets AS t
20758- ON s.address = t.event_session_address
20759- WHERE s.name = @EventSessionName
20760- AND t.target_name IN (N'event_file', N'ring_buffer')
20761- ORDER BY t.target_name
20762- OPTION(RECOMPILE);
20768+ SELECT TOP (1)
20769+ @TargetSessionType = t.target_name
20770+ FROM sys.dm_xe_database_sessions AS s
20771+ JOIN sys.dm_xe_database_session_targets AS t
20772+ ON s.address = t.event_session_address
20773+ WHERE s.name = @EventSessionName
20774+ AND t.target_name IN (N'event_file', N'ring_buffer')
20775+ ORDER BY t.target_name
20776+ OPTION(RECOMPILE);
2076320777
20764- RAISERROR('@TargetSessionType assigned as %s for Azure', 0, 1, @TargetSessionType) WITH NOWAIT;
20765- END;
20778+ RAISERROR('@TargetSessionType assigned as %s for Azure', 0, 1, @TargetSessionType) WITH NOWAIT;
20779+ END;
2076620780
2076720781
2076820782 /*The system health stuff gets handled different from user extended events.*/
@@ -23460,6 +23474,7 @@ BEGIN
2346023474 AND (d.client_app = @AppName OR @AppName IS NULL)
2346123475 AND (d.host_name = @HostName OR @HostName IS NULL)
2346223476 AND (d.login_name = @LoginName OR @LoginName IS NULL)
23477+ AND (d.deadlock_type = @DeadlockType OR @DeadlockType IS NULL)
2346323478 OPTION (RECOMPILE, LOOP JOIN, HASH JOIN);
2346423479
2346523480 UPDATE d
@@ -23847,7 +23862,11 @@ BEGIN
2384723862 deqs.max_reserved_threads,
2384823863 deqs.min_used_threads,
2384923864 deqs.max_used_threads,
23850- deqs.total_rows
23865+ deqs.total_rows,
23866+ max_worker_time_ms =
23867+ deqs.max_worker_time / 1000.,
23868+ max_elapsed_time_ms =
23869+ deqs.max_elapsed_time / 1000.
2385123870 INTO #dm_exec_query_stats
2385223871 FROM sys.dm_exec_query_stats AS deqs
2385323872 WHERE EXISTS
@@ -23879,8 +23898,10 @@ BEGIN
2387923898 ap.executions_per_second,
2388023899 ap.total_worker_time_ms,
2388123900 ap.avg_worker_time_ms,
23901+ ap.max_worker_time_ms,
2388223902 ap.total_elapsed_time_ms,
2388323903 ap.avg_elapsed_time_ms,
23904+ ap.max_elapsed_time_ms,
2388423905 ap.total_logical_reads_mb,
2388523906 ap.total_physical_reads_mb,
2388623907 ap.total_logical_writes_mb,
@@ -23923,7 +23944,9 @@ BEGIN
2392323944 c.min_used_threads,
2392423945 c.max_used_threads,
2392523946 c.total_rows,
23926- c.query_plan
23947+ c.query_plan,
23948+ c.max_worker_time_ms,
23949+ c.max_elapsed_time_ms
2392723950 FROM #available_plans AS ap
2392823951 OUTER APPLY
2392923952 (
@@ -24074,6 +24097,8 @@ BEGIN
2407424097 @TargetSessionType,
2407524098 VictimsOnly =
2407624099 @VictimsOnly,
24100+ DeadlockType =
24101+ @DeadlockType,
2407724102 Debug =
2407824103 @Debug,
2407924104 Help =
@@ -24178,7 +24203,7 @@ BEGIN
2417824203 SET STATISTICS XML OFF;
2417924204 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
2418024205
24181- SELECT @Version = '8.20 ', @VersionDate = '20240522 ';
24206+ SELECT @Version = '8.21 ', @VersionDate = '20240701 ';
2418224207
2418324208 IF(@VersionCheckMode = 1)
2418424209 BEGIN
0 commit comments