Skip to content

Commit 731c746

Browse files
Merge fix/healthparser-pending-task-threshold into dev
2 parents 7a9919f + c460316 commit 731c746

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

sp_HealthParser/sp_HealthParser.sql

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,7 +2951,11 @@ AND ca.utc_timestamp < @end_date';
29512951
CROSS APPLY wi.sp_server_diagnostics_component_result.nodes('/event') AS w(x)
29522952
WHERE w.x.exist('(data[@name="component"]/text[.= "QUERY_PROCESSING"])') = 1
29532953
AND (w.x.exist('(data[@name="state"]/text[.= "WARNING"])') = @warnings_only OR @warnings_only = 0)
2954-
AND (w.x.exist('(/event/data[@name="data"]/value/queryProcessing/@pendingTasks[.>= sql:variable("@pending_task_threshold")])') = 1 OR @warnings_only = 0)
2954+
/* Threshold is honored whether or not @warnings_only is set — the
2955+
parameter documents "minimum pending tasks to display" and the
2956+
previous `OR @warnings_only = 0` short-circuit silently ignored
2957+
the user-supplied value whenever warnings-only was off. */
2958+
AND w.x.exist('(/event/data[@name="data"]/value/queryProcessing/@pendingTasks[.>= sql:variable("@pending_task_threshold")])') = 1
29552959
OPTION(RECOMPILE, MAXDOP 1);
29562960

29572961
IF @debug = 1
@@ -3176,7 +3180,10 @@ AND ca.utc_timestamp < @end_date';
31763180
INTO #pending_task_details
31773181
FROM #sp_server_diagnostics_component_result AS wi
31783182
CROSS APPLY wi.sp_server_diagnostics_component_result.nodes('/event') AS w(x)
3179-
CROSS APPLY w.x.nodes('/event/data[@name="data"]/value/queryProcessing[@pendingTasks > 1]/pendingTasks/entryPoint') AS ep(e)
3183+
/* Hardcoded threshold > 1 ignored the @pending_task_threshold
3184+
parameter. Replaced with sql:variable() binding so the user's
3185+
value actually takes effect here too. */
3186+
CROSS APPLY w.x.nodes('/event/data[@name="data"]/value/queryProcessing[@pendingTasks >= sql:variable("@pending_task_threshold")]/pendingTasks/entryPoint') AS ep(e)
31803187
WHERE w.x.exist('(data[@name="component"]/text[.= "QUERY_PROCESSING"])') = 1
31813188
AND (w.x.exist('(data[@name="state"]/text[.= "WARNING"])') = @warnings_only OR @warnings_only = 0)
31823189
OPTION(RECOMPILE, MAXDOP 1);

0 commit comments

Comments
 (0)