From 2a4eb014294bf70ff06479a443fc2c2aa077b68b Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Fri, 20 Feb 2026 08:37:07 -0500 Subject: [PATCH] Exclude WAITFOR sessions from long-running query alerts CDC capture agents use `waitfor delay @waittime` and run indefinitely by design. Service Broker listeners use `waitfor receive`. Neither should trigger long-running query alerts. Adds NOT LIKE filters for both patterns in Dashboard (live DMV query) and Lite (DuckDB alert query). Fixes #151. Co-Authored-By: Claude Opus 4.6 --- Dashboard/Services/DatabaseService.NocHealth.cs | 2 ++ Lite/Services/LocalDataService.WaitStats.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Dashboard/Services/DatabaseService.NocHealth.cs b/Dashboard/Services/DatabaseService.NocHealth.cs index e5125e3d..c1f59887 100644 --- a/Dashboard/Services/DatabaseService.NocHealth.cs +++ b/Dashboard/Services/DatabaseService.NocHealth.cs @@ -623,6 +623,8 @@ CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS t JOIN sys.dm_exec_sessions AS s ON s.session_id = r.session_id WHERE r.session_id > 50 AND r.total_elapsed_time >= @thresholdMs + AND t.text NOT LIKE N'%waitfor delay%' + AND t.text NOT LIKE N'%waitfor receive%' ORDER BY r.total_elapsed_time DESC OPTION(MAXDOP 1, RECOMPILE);"; diff --git a/Lite/Services/LocalDataService.WaitStats.cs b/Lite/Services/LocalDataService.WaitStats.cs index 46994844..f7f1a313 100644 --- a/Lite/Services/LocalDataService.WaitStats.cs +++ b/Lite/Services/LocalDataService.WaitStats.cs @@ -218,6 +218,8 @@ FROM v_query_snapshots AND collection_time = (SELECT MAX(collection_time) FROM v_query_snapshots WHERE server_id = $1) AND session_id > 50 AND total_elapsed_time_ms >= $2 +AND query_text NOT LIKE '%waitfor delay%' +AND query_text NOT LIKE '%waitfor receive%' ORDER BY total_elapsed_time_ms DESC LIMIT 5";