Commit 7e48494
Fix query_stats collector causing SQL dumps on passive mirrors (#632)
Removed CROSS APPLY sys.dm_exec_plan_attributes and the direct
sys.databases join. Both dm_exec_plan_attributes and dm_exec_sql_text
can trigger severity 22 engine crashes when plan handles reference
RESTORING databases on passive mirror servers.
Now pre-builds a temp table of ONLINE, accessible database IDs
(filtered by state = 0 + HAS_DBACCESS) before the main query runs.
The staging INSERT joins to this temp table instead of sys.databases,
preventing any DMV from being evaluated against RESTORING databases.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 9a673cf commit 7e48494
1 file changed
Lines changed: 35 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
225 | 257 | | |
226 | 258 | | |
227 | 259 | | |
| |||
274 | 306 | | |
275 | 307 | | |
276 | 308 | | |
277 | | - | |
| 309 | + | |
278 | 310 | | |
279 | 311 | | |
280 | 312 | | |
| |||
353 | 385 | | |
354 | 386 | | |
355 | 387 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 388 | + | |
| 389 | + | |
365 | 390 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | 391 | | |
374 | 392 | | |
375 | 393 | | |
| |||
0 commit comments