@@ -18,7 +18,8 @@ ALTER PROCEDURE
18
18
@EventSessionName sysname = N' system_health' ,
19
19
@TargetSessionType sysname = NULL ,
20
20
@VictimsOnly bit = 0 ,
21
- @Debug bit = 0 ,
21
+ @DeadlockType nvarchar(20 ) = NULL ,
22
+ @Debug bit = 0 ,
22
23
@Help bit = 0 ,
23
24
@Version varchar (30 ) = NULL OUTPUT,
24
25
@VersionDate datetime = NULL OUTPUT,
@@ -198,7 +199,7 @@ BEGIN
198
199
@StartDateOriginal datetime = @StartDate,
199
200
@EndDateOriginal datetime = @EndDate,
200
201
@StartDateUTC datetime,
201
- @EndDateUTC datetime;
202
+ @EndDateUTC datetime;;
202
203
203
204
/* Temporary objects used in the procedure*/
204
205
DECLARE
@@ -708,50 +709,63 @@ BEGIN
708
709
END CATCH;
709
710
END;
710
711
712
+ IF @DeadlockType IS NOT NULL
713
+ BEGIN
714
+ SELECT
715
+ @DeadlockType =
716
+ CASE
717
+ WHEN LOWER (@DeadlockType) LIKE ' regular%'
718
+ THEN N' Regular Deadlock'
719
+ WHEN LOWER (@DeadlockType) LIKE N' parallel%'
720
+ THEN N' Parallel Deadlock'
721
+ ELSE NULL
722
+ END;
723
+ END;
724
+
711
725
/* If @TargetSessionType, we need to figure out if it's ring buffer or event file*/
712
726
/* Azure has differently named views, so we need to separate. Thanks, Azure.*/
713
727
714
- IF
715
- (
716
- @Azure = 0
717
- AND @TargetSessionType IS NULL
718
- )
719
- BEGIN
720
- RAISERROR(' @TargetSessionType is NULL, assigning for non-Azure instance' , 0 , 1 ) WITH NOWAIT;
721
-
722
- SELECT TOP (1 )
723
- @TargetSessionType = t .target_name
724
- FROM sys .dm_xe_sessions AS s
725
- JOIN sys .dm_xe_session_targets AS t
726
- ON s .address = t .event_session_address
727
- WHERE s .name = @EventSessionName
728
- AND t .target_name IN (N' event_file' , N' ring_buffer' )
729
- ORDER BY t .target_name
730
- OPTION(RECOMPILE);
731
-
732
- RAISERROR(' @TargetSessionType assigned as %s for non-Azure' , 0 , 1 , @TargetSessionType) WITH NOWAIT;
733
- END;
728
+ IF
729
+ (
730
+ @Azure = 0
731
+ AND @TargetSessionType IS NULL
732
+ )
733
+ BEGIN
734
+ RAISERROR(' @TargetSessionType is NULL, assigning for non-Azure instance' , 0 , 1 ) WITH NOWAIT;
735
+
736
+ SELECT TOP (1 )
737
+ @TargetSessionType = t .target_name
738
+ FROM sys .dm_xe_sessions AS s
739
+ JOIN sys .dm_xe_session_targets AS t
740
+ ON s .address = t .event_session_address
741
+ WHERE s .name = @EventSessionName
742
+ AND t .target_name IN (N' event_file' , N' ring_buffer' )
743
+ ORDER BY t .target_name
744
+ OPTION(RECOMPILE);
734
745
735
- IF
736
- (
737
- @Azure = 1
738
- AND @TargetSessionType IS NULL
739
- )
740
- BEGIN
741
- RAISERROR(' @TargetSessionType is NULL, assigning for Azure instance' , 0 , 1 ) WITH NOWAIT;
746
+ RAISERROR(' @TargetSessionType assigned as %s for non-Azure' , 0 , 1 , @TargetSessionType) WITH NOWAIT;
747
+ END;
742
748
743
- SELECT TOP (1 )
744
- @TargetSessionType = t .target_name
745
- FROM sys .dm_xe_database_sessions AS s
746
- JOIN sys .dm_xe_database_session_targets AS t
747
- ON s .address = t .event_session_address
748
- WHERE s .name = @EventSessionName
749
- AND t .target_name IN (N' event_file' , N' ring_buffer' )
750
- ORDER BY t .target_name
751
- OPTION(RECOMPILE);
749
+ IF
750
+ (
751
+ @Azure = 1
752
+ AND @TargetSessionType IS NULL
753
+ )
754
+ BEGIN
755
+ RAISERROR(' @TargetSessionType is NULL, assigning for Azure instance' , 0 , 1 ) WITH NOWAIT;
756
+
757
+ SELECT TOP (1 )
758
+ @TargetSessionType = t .target_name
759
+ FROM sys .dm_xe_database_sessions AS s
760
+ JOIN sys .dm_xe_database_session_targets AS t
761
+ ON s .address = t .event_session_address
762
+ WHERE s .name = @EventSessionName
763
+ AND t .target_name IN (N' event_file' , N' ring_buffer' )
764
+ ORDER BY t .target_name
765
+ OPTION(RECOMPILE);
752
766
753
- RAISERROR(' @TargetSessionType assigned as %s for Azure' , 0 , 1 , @TargetSessionType) WITH NOWAIT;
754
- END;
767
+ RAISERROR(' @TargetSessionType assigned as %s for Azure' , 0 , 1 , @TargetSessionType) WITH NOWAIT;
768
+ END;
755
769
756
770
757
771
/* The system health stuff gets handled different from user extended events.*/
@@ -3449,7 +3463,8 @@ BEGIN
3449
3463
AND (d .client_app = @AppName OR @AppName IS NULL )
3450
3464
AND (d .host_name = @HostName OR @HostName IS NULL )
3451
3465
AND (d .login_name = @LoginName OR @LoginName IS NULL )
3452
- OPTION (RECOMPILE, LOOP JOIN , HASH JOIN );
3466
+ AND (d .deadlock_type = @DeadlockType OR @DeadlockType IS NULL )
3467
+ OPTION (RECOMPILE, LOOP JOIN , HASH JOIN );
3453
3468
3454
3469
UPDATE d
3455
3470
SET d .inputbuf =
@@ -4063,6 +4078,8 @@ BEGIN
4063
4078
@TargetSessionType,
4064
4079
VictimsOnly =
4065
4080
@VictimsOnly,
4081
+ DeadlockType =
4082
+ @DeadlockType,
4066
4083
Debug =
4067
4084
@Debug,
4068
4085
Help =
0 commit comments