Commit c01543b
Guard sp_HumanEventsBlockViewer recursive blocking-tree against cycles
The blocking-hierarchy CTE (lines ~2145-2203) used OPTION(MAXRECURSION 0),
removing the default safety ceiling entirely. Two sessions can
legitimately appear to block each other in the same monitor_loop
window — before the deadlock monitor resolves — and the recursive
join bg.blocking_desc = h.blocked_desc has no cycle check. Once an
anchor row feeds into a cycle in the blocked tree, the CTE has no
exit and the UPDATE runs until tempdb fills.
Added a guard to the recursive step:
WHERE h.sort_order NOT LIKE '%' + bg.blocked_desc + '%'
sort_order already accumulates every (SPID:ECID) visited on this
branch, so a LIKE check against the candidate blocked_desc breaks
the recursion before a revisit. Reverted MAXRECURSION 0 to
MAXRECURSION 100 as a backstop in case an unexpected blocked_desc
format slips past the LIKE guard — hitting 100 raises a catchable
error instead of running unbounded.
Verified in isolation:
start→a, a→b, b→a (chain into cycle):
Without guard, MAXRECURSION 100: "maximum recursion ... exhausted"
With guard: two rows returned (start→a at level 0, a→b at level 1),
the b→a edge that would close the cycle is correctly skipped
Normal chain 1→2→3→4: three rows, all levels populated (regression check)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ca2dbd8 commit c01543b
1 file changed
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2189 | 2189 | | |
2190 | 2190 | | |
2191 | 2191 | | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
2192 | 2201 | | |
2193 | 2202 | | |
2194 | 2203 | | |
| |||
2200 | 2209 | | |
2201 | 2210 | | |
2202 | 2211 | | |
2203 | | - | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
2204 | 2219 | | |
2205 | 2220 | | |
2206 | 2221 | | |
| |||
0 commit comments