Skip to content

Commit 6b46af9

Browse files
authored
Merge pull request #3893 from BrentOzarULTD/3892_blitzlock_azure_system_health
sp_BlitzLock: graceful message on Azure SQL DB #3892
2 parents 3fafcb0 + 07303a5 commit 6b46af9

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

sp_BlitzLock.sql

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,38 @@ BEGIN
570570
AND dxs.create_time IS NOT NULL
571571
)
572572
BEGIN
573-
RAISERROR('A session with the name %s does not exist or is not currently active.', 11, 1, @EventSessionName) WITH NOWAIT;
574-
RETURN;
573+
IF @EventSessionName = N'system_health'
574+
AND NOT EXISTS
575+
(
576+
SELECT
577+
1/0
578+
FROM sys.database_event_sessions AS ses
579+
WHERE ses.name = @EventSessionName
580+
)
581+
BEGIN
582+
RAISERROR('
583+
The system_health extended events session is not available in Azure SQL DB.
584+
585+
To use sp_BlitzLock in Azure SQL DB, you have two options:
586+
587+
1. Create a database-scoped deadlock XE session, e.g.:
588+
589+
CREATE EVENT SESSION [deadlocks] ON DATABASE
590+
ADD EVENT sqlserver.database_xml_deadlock_report
591+
ADD TARGET package0.ring_buffer;
592+
ALTER EVENT SESSION [deadlocks] ON DATABASE STATE = START;
593+
594+
Then call: EXEC sp_BlitzLock @EventSessionName = N''deadlocks'', @TargetSessionType = N''ring_buffer'';
595+
596+
2. Log deadlock XML to a table and use the @TargetTableName parameter.
597+
', 0, 1) WITH NOWAIT;
598+
RETURN;
599+
END;
600+
ELSE
601+
BEGIN
602+
RAISERROR('A session with the name %s does not exist or is not currently active.', 11, 1, @EventSessionName) WITH NOWAIT;
603+
RETURN;
604+
END;
575605
END;
576606
END;
577607

0 commit comments

Comments
 (0)