debugsqlMinor
Why is deadlock alert not working?
Viewed 0 times
whydeadlockworkingnotalert
Problem
I created a deadlock alert including notification to an operator like this:
This alert is registered for notification.
It's history says it never appeared although it is in place for months and there are multiple deadlocks per day. I created a deadlock manually. It shows up in the Log File.
What is missing for this alert to raise a notification?
Other notifications like e.g. 18456 Invalid Login work fine.
EXEC msdb.dbo.sp_add_alert @name=N'1205 Deadlock',
@message_id=1205,
@severity=0,
@enabled=1,
@delay_between_responses=30,
@include_event_description_in=1,
@database_name=N'myDB',
@category_name=N'[Uncategorized]',
@job_id=N'00000000-0000-0000-0000-000000000000';This alert is registered for notification.
It's history says it never appeared although it is in place for months and there are multiple deadlocks per day. I created a deadlock manually. It shows up in the Log File.
What is missing for this alert to raise a notification?
Other notifications like e.g. 18456 Invalid Login work fine.
Solution
Probably the error 1205 is not set up to be logged in
If the column
The documentation for
Remarks
sp_add_alert must be run from the msdb database.
These are the circumstances under which errors/messages generated by SQL Server and SQL Server applications are sent to the Windows application log and can therefore raise alerts:
ERRORLOG. Look it up in sys.messages:SELECT *
FROM sys.messages
WHERE message_id = 1205;If the column
is_event_logged is set to 0, change it this way:EXEC master.sys.sp_altermessage
@message_id = 1205,
@parameter = 'WITH_LOG',
@parameter_value = 'true';The documentation for
sp_add_alert describes under which conditions an alert is raised:Remarks
sp_add_alert must be run from the msdb database.
These are the circumstances under which errors/messages generated by SQL Server and SQL Server applications are sent to the Windows application log and can therefore raise alerts:
- Severity 19 or higher sys.messages errors
- Any
RAISERRORstatement invoked withWITH LOGsyntax
- Any sys.messages error modified or created using sp_altermessage
- Any event logged using xp_logevent
Code Snippets
SELECT *
FROM sys.messages
WHERE message_id = 1205;EXEC master.sys.sp_altermessage
@message_id = 1205,
@parameter = 'WITH_LOG',
@parameter_value = 'true';Context
StackExchange Database Administrators Q#132495, answer score: 8
Revisions (0)
No revisions yet.