Repository navigation
Thread cancellation through 5 more web reads: 2 trends, 3 analysis (#4203) - #4411
Merged
Merged
Conversation
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
get_file_io_trend,get_perfmon_trend,compare_analysis,get_analysis_factsandget_analysis_findingswere still on the web endpoint'sCancellationAllowlist, so an abandoned browser request to any of them kept running its store reads (and, for the three analysis tools, the inference engine's fact collection and scoring) to completion instead of stopping when the client gave up.What changes
get_file_io_trend,get_perfmon_trend(DarlingMcpTrendTools.cs): added a trailingCancellationToken cancellationToken = default, threaded to every store call (series/points/buckets, distinct-counter probe, has-any-stat probe, baseline discontinuities, server resolution, not-collected status), narrowed the catch towhen (ex is not OperationCanceledException).compare_analysis,get_analysis_facts,get_analysis_findings(DarlingMcpTools.cs): same pattern.DarlingAnalysisService.CollectAndScoreFactsAsyncandComparePeriodsAsyncgained an optional trailingcancellationTokenthat setsAnalysisContext.CancellationToken(both already had default-token store calls hung off that context, so nothing else needed to change downstream ofResolveEngineAsync).GetRecentFindingsAsync(service wrapper andPgFindingStore) gained the same optional parameter, threaded into the store's connection open / reader calls.DarlingForcePlanTargetStateReader.TryReadAsyncalready acceptedcancellationToken; both findings-read call sites now pass it.DarlingWebEndpoints.cs: removed all 5 tools fromCancellationAllowlistand updated their dispatch entries to passcancellationToken: c.RequestAborted.No other tool file touched. Two sibling #4203 slices are running on other branches and also edit the allowlist/dispatch table in this same file; the coordinator resolves that merge conflict.
Test plan
dotnet build Darling/Darling.Tests/Darling.Tests.csproj -c Release -p:EnableWindowsTargeting=true— 0 errors, 2 warnings (pre-existing).dotnet build Lite.Tests/Lite.Tests.csproj -c Release -p:EnableWindowsTargeting=true— 0 errors, 0 warnings.WebReadCancellationPinTestsrun in-process on macOS (net10.0 host, WindowsDesktop framework entry stripped from the runtimeconfig): Total: 127, Errors: 0, Failed: 0, Skipped: 0. This suite is the reflection ratchet (EveryStoreReadingToolMethod_TakesACancellationToken_UnlessAllowlisted,CancellationAllowlist_HasNoStaleEntry) — leaving the allowlist makes it enforce these 5 tools going forward. RED case on the pre-fix code: any of the 5 dispatch entries still calling the tool method withoutcancellationToken: c.RequestAbortedfailsEveryStoreReadingToolMethod_TakesACancellationToken_UnlessAllowlisted(the entry is no longer allowlisted but its lambda drops the token), or, before this change, the tool methods themselves had noCancellationTokenparameter to pass.Darling.Tests.dll/Lite.Tests.dllfull Windows-targeted suites: not run here (net10.0-windows classes build but do not execute on macOS beyond the in-process runner used above); CI decides them.CHANGELOG entry
SECTION: Fixed
ENTRY:
get_file_io_trend,get_perfmon_trend,compare_analysis,get_analysis_factsandget_analysis_findingskept running their store reads (and, for the analysis tools, the inference engine's fact collection and scoring) to completion after a web request was abandoned. They now take a cancellation token and stop when the client disconnects.REF:
[Thread cancellation through 5 more web reads: 2 trends, 3 analysis (#4203) #4411]: Thread cancellation through 5 more web reads: 2 trends, 3 analysis (#4203) #4411