Repository navigation
Thread cancellation through 5 PostgreSQL web reads (#4203) - #4409
Merged
Merged
Conversation
get_pg_index_bloat, get_pg_column_stats, get_pg_cpu_utilization, get_pg_log_events and get_pg_logging_audit 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 the five from CancellationAllowlist.
erikdarlingdata
marked this pull request as ready for review
September 26, 2026 13:34
This was referenced Sep 26, 2026
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
An abandoned web request for a PostgreSQL-target read still ran its store query to completion, because these five tools took no
CancellationTokenand could not stop a query the caller had already given up on.What changes
Five tools under
Darling/PerformanceMonitor.Darling.Service/Mcp/now take a trailingCancellationToken cancellationToken = defaultand pass it into every store call they make (resolver, coverage/precondition checks, the row reads, not-collected status), following the pattern of #4357/#4359:DarlingMcpPgIndexTools.cs—get_pg_index_bloat,get_pg_column_statsDarlingMcpPgCpuUtilizationTools.cs—get_pg_cpu_utilizationDarlingMcpPgLogEventTools.cs—get_pg_log_eventsDarlingMcpPgLoggingAuditTools.cs—get_pg_logging_auditEach tool's
catchblock is narrowed towhen (ex is not OperationCanceledException). All five storage-layer methods these tools call already accepted aCancellationTokenparameter, so no shared-helper signature changed.The five tools are removed from
DarlingWebEndpoints.CancellationAllowlist, and their dispatch entries now passcancellationToken: c.RequestAborted(or the equivalent positional argument for theget_pg_cpu_utilization/get_pg_index_bloat/get_pg_column_stats/get_pg_log_eventscalls).Lite: N/A, no
/api/readsurface exposes these tools.Test plan
dotnet build Darling/Darling.Tests/Darling.Tests.csproj -p:EnableWindowsTargeting=true— 0 warnings-relevant errors, 0 errors.dotnet build Lite.Tests/Lite.Tests.csproj -p:EnableWindowsTargeting=true— 0 errors (both build-only on macOS; Windows-only, CI decides them at runtime).WebReadCancellationPinTestsin-process on macOS: Total: 127, Errors: 0, Failed: 0. This is a reflection ratchet over every non-allowlisted dispatch entry (EveryStoreReadingToolMethod_TakesACancellationToken_UnlessAllowlisted,CancellationAllowlist_HasNoStaleEntry); before this change these 5 tools were still on the allowlist with noCancellationTokenparameter, so the ratchet passed them by construction (RED case: had one of the five been removed from the allowlist without adding the parameter and dispatch argument,EveryStoreReadingToolMethod_TakesACancellationToken_UnlessAllowlistedwould fail on that dispatch entry for droppingc.RequestAborted).PgTargetMcpSurfaceTests(3/3),McpServiceParameterDiSeatCensusTests(1/1) in-process — both green.EngineCapabilityMissTestsandRuntimePreconditionMissTestswere not found as test classes in this assembly (0 discovered), so nothing to run there.CHANGELOG entry
SECTION: Fixed
ENTRY:
REF:
[Thread cancellation through 5 PostgreSQL web reads (#4203) #4409]: Thread cancellation through 5 PostgreSQL web reads (#4203) #4409