Repository navigation
Thread cancellation through 15 core web reads (#4203) - #4387
Merged
Merged
Conversation
get_cpu_utilization, get_wait_stats, get_wait_types, get_wait_trend, get_memory_stats, get_memory_clerks, get_file_io_stats, get_tempdb_trend, get_perfmon_stats, get_query_store_top, list_servers, get_collection_health, get_collection_log and get_current_waits_trend/get_blocking_stats now take a CancellationToken and pass it to every store call, so an abandoned web request stops its query instead of running to completion. Removes them from CancellationAllowlist.
…ion in get_wait_trend
…ellation-8 # Conflicts: # Darling/PerformanceMonitor.Darling.Service/DarlingWebEndpoints.cs
erikdarlingdata
marked this pull request as ready for review
September 26, 2026 06:00
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.
Refs #4203.
Why
DarlingWebEndpoints.CancellationAllowlist listed 15 tools in DarlingMcpDataTools.cs whose dispatch entries did not thread
c.RequestAbortedthrough, so an abandoned web-viewer request kept running its store query to completion instead of stopping.What changes
Added a trailing
CancellationToken cancellationToken = defaultparameter (no[Description]) to each tool method below, passed it to every store call in the body (resolver, reader calls, engine-capability/runtime-precondition probes, memoized reads), narrowed eachcatch (Exception ex)towhen (ex is not OperationCanceledException), removed the tool fromCancellationAllowlist, and updated itsDarlingWebEndpointsdispatch entry to passcancellationToken: c.RequestAborted:GetCollectionLogFleetAsync)All 15 were allowlisted in
DarlingWebEndpoints.csand defined inDarlingMcpDataTools.cs;get_top_queries_by_cpu,get_top_procedures_by_cpu, andget_server_propertiesare also defined there but were NOT in the allowlist, so they are untouched by this slice.Every reader/helper call site below the tools (
DarlingDataReader.*,DarlingServerResolver.ResolveOrErrorAsync,DarlingEngineCapability.NotCollectedStatusAsync,DarlingRuntimePrecondition.*,DarlingTrendReader.*,DarlingBlockingTrendReader.*) already accepted an optionalCancellationToken cancellationToken = default, so no reader signatures changed — except one shared helper:Shared-helper signature change:
DarlingServerResolver.ResolveOrErrorWithFleetSentinelAsyncgained a trailingCancellationToken cancellationToken = default(get_collection_log is the only caller on this SKU, so no other caller needed updating).Test plan
dotnet build Darling/Darling.Tests/Darling.Tests.csproj -p:EnableWindowsTargeting=true— 0 Warning(s)/0 Error(s) beyond the pre-existing warning count (1 warning, 0 errors).dotnet build Lite.Tests/Lite.Tests.csproj -p:EnableWindowsTargeting=true— 0 Warning(s)/0 Error(s).Darling/Darling.Tests/WebReadCancellationPinTests.cs'sEveryStoreReadingToolMethod_TakesACancellationToken_UnlessAllowlistedreflection ratchet previously passed only because these 15 tools were allowlisted (an exemption from the token requirement);CancellationAllowlist_HasNoStaleEntryalso previously passed trivially since all 15 were still-valid allowlist entries. Removing them from the allowlist without adding the token parameter would have madeEveryStoreReadingToolMethod_TakesACancellationToken_UnlessAllowlistedfail RED (a dispatch entry with noc.RequestAbortedthreaded through, matching the ratchet's own description); this PR adds the token to every one of the 15 dispatch entries, so on dev's pre-fix code (allowlist entry present, no token) the ratchet was silently non-failing by construction — the RED state proven here is: reverting the allowlist removal alone (leaving the token additions) would tripCancellationAllowlist_HasNoStaleEntry(a stale allowlist entry for a tool that now takes a token), and reverting the token additions alone (leaving the allowlist removal) tripsEveryStoreReadingToolMethod_TakesACancellationToken_UnlessAllowlisted.PgTargetMcpSurfaceTests,McpServiceParameterDiSeatCensusTests,EngineCapabilityMissTests,RuntimePreconditionMissTestslocally (Windows-only); grepped and none of the 15 touched tools' catch-clause narrowing or parameter additions should change their existing assertions, since no response shape or parameter count/order changed other than the appended token.CHANGELOG entry
SECTION: Fixed
ENTRY:
get_cpu_utilization,get_wait_stats,get_wait_types,get_wait_trend,get_memory_stats,get_memory_clerks,get_file_io_stats,get_tempdb_trend,get_perfmon_stats,get_query_store_top,list_servers,get_collection_health,get_collection_log,get_current_waits_trendandget_blocking_statsused to run their store query to completion even after the web viewer's request was aborted; each now takes aCancellationTokenthreaded to every store call, so an abandoned request stops promptly.REF:
[Thread cancellation through 15 core web reads (#4203) #4387]: Thread cancellation through 15 core web reads (#4203) #4387