Commit 344fff5
Fix sp_PerfCheck deadlock check for sub-day uptime
The deadlock rate check (check_id 5103) divided the cumulative
deadlock count by DATEDIFF(DAY, sqlserver_start_time, SYSDATETIME())
wrapped in NULLIF(..., 0). For any server whose uptime had not yet
crossed a calendar-day boundary, DATEDIFF(DAY, ...) returned 0,
NULLIF collapsed the divisor to NULL, and the resulting
`rate > 9` comparison evaluated as UNKNOWN in the WHERE clause —
which filters out the row, skipping the check entirely.
The details CASE already had an ELSE branch formatted for "X
deadlocks in Y hours since startup", but that branch was
unreachable because WHERE never let a low-uptime row through.
Rewrote the priority CASE and WHERE rate calculation to use
DATEDIFF(SECOND, ...) with a *86400.0 scale factor, preserving
the "more than 9 per day" threshold semantics while working for
any uptime >= 1 second. DATEDIFF(SECOND) has ~68 years of
safe range so overflow is not a concern.
Verified on SQL Server 2022 with 3 days uptime and 725
deadlocks/day: the check now fires with priority 20 (High).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ca2dbd8 commit 344fff5
1 file changed
Lines changed: 17 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1007 | 1007 | | |
1008 | 1008 | | |
1009 | 1009 | | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
1010 | 1018 | | |
1011 | 1019 | | |
1012 | 1020 | | |
1013 | 1021 | | |
1014 | | - | |
1015 | | - | |
| 1022 | + | |
| 1023 | + | |
1016 | 1024 | | |
1017 | 1025 | | |
1018 | 1026 | | |
1019 | 1027 | | |
1020 | | - | |
| 1028 | + | |
1021 | 1029 | | |
1022 | 1030 | | |
1023 | 1031 | | |
| |||
1027 | 1035 | | |
1028 | 1036 | | |
1029 | 1037 | | |
1030 | | - | |
1031 | | - | |
| 1038 | + | |
| 1039 | + | |
1032 | 1040 | | |
1033 | 1041 | | |
1034 | 1042 | | |
1035 | 1043 | | |
1036 | | - | |
| 1044 | + | |
1037 | 1045 | | |
1038 | 1046 | | |
1039 | 1047 | | |
| |||
1074 | 1082 | | |
1075 | 1083 | | |
1076 | 1084 | | |
1077 | | - | |
1078 | | - | |
| 1085 | + | |
| 1086 | + | |
1079 | 1087 | | |
1080 | 1088 | | |
1081 | 1089 | | |
1082 | 1090 | | |
1083 | | - | |
| 1091 | + | |
1084 | 1092 | | |
1085 | 1093 | | |
1086 | 1094 | | |
| |||
0 commit comments