Add RESTORING database filter to waiting_tasks collector (#430)#434
Merged
erikdarlingdata merged 1 commit intodevfrom Mar 5, 2026
Merged
Add RESTORING database filter to waiting_tasks collector (#430)#434erikdarlingdata merged 1 commit intodevfrom
erikdarlingdata merged 1 commit intodevfrom
Conversation
The waiting_tasks collector joins sys.databases without filtering d.state = 0 (ONLINE), which means sessions running in the context of a RESTORING database (mirroring passive/AG secondary) can pass through to sys.dm_exec_sql_text and sys.dm_exec_text_query_plan. While the dumps in #430 turned out to be an internal SQL Server 2016 background thread crash (not our collector), this hardens the waiting_tasks collector to match the pattern already used in query_stats, procedure_stats, query_store, and file_io_stats collectors (PR #385). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
d.state = 0filter to thesys.databasesjoin in the waiting_tasks collectorsys.dm_exec_sql_textandsys.dm_exec_text_query_planContext
Issue #430 reported SQL dumps on a mirroring passive server. WinDbg analysis of the dumps showed the crashes are from an internal SQL Server 2016 background thread (spid 40,
m_fBackground=1), not from our collectors. However, the waiting_tasks collector was the only one still missing the RESTORING database guard — this closes that gap.Test plan
AND d.state = 0to the LEFT JOIN condition🤖 Generated with Claude Code