Skip to content

Add authored alert notebooks for Long-Running Query and Forced Plan Failing (#4223) - #4418

Merged
erikdarlingdata merged 1 commit into
devfrom
fix/4223-notebook-long-query-forced-plan
Sep 26, 2026
Merged

erikdarlingdata merged 1 commit into
devfrom
fix/4223-notebook-long-query-forced-plan

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Refs #4223.

Why

Long-Running Query and Forced Plan Failing alerts opened the mechanical fallback notebook (a plain list of the triage endpoint's reads for the metric) instead of an authored one shaped for what each alert is actually about.

What changes

New file AlertNotebookEndpoint.Templates.QueryPlans.cs adds two builders and registers both metrics with one row each in s_authoredTemplates.

Family Cells
Long-Running Query Header, Status, get_active_queries (limit 25), a markdown note that the plan for a still-running session is one click away in that row, a completion-duration timeline (long_query_completions), get_long_query_completions (limit 20)
Forced Plan Failing Header, Status, get_plan_corrections (limit 25, full text), a plan-corrections timeline by recommendation_state (plan_correction / plan_correction_captures)

get_plan_xml requires a concrete query_hash. Neither AlertIncident nor the persisted alert-history row carries that hash as data — LongRunningQueryIncidents folds it into the fingerprint's dedup key instead of exposing it — so the notebook cannot bind an auto-run cell to it. The template omits the read and adds a markdown note pointing at the click-through in the get_active_queries row instead. A pin (LongRunningQuery_NeverEmitsAGetPlanXmlCell) checks this stays true.

get_query_store_regressions is the issue's own click-to-run read. The notebook schema (DarlingWebEndpoints.ValidateNotebookDefinition) has no non-auto-run cell type — every read cell runs on open — so the template omits it entirely rather than running it eagerly against the issue's stated intent. A pin (ForcedPlanFailing_NeverEmitsGetQueryStoreRegressionsAsAnAutoRunCell) checks it never appears as a read cell.

Test plan

New file AlertNotebookTemplateQueryPlansTests.cs (8 tests): routing for both metrics, the exact cell list for each, the query_hash non-binding pin, the get_query_store_regressions non-auto-run pin, and a no-matched-incident degrade with the same cell count for each family.

  • RED on origin/dev (5899b85): all 8 new tests fail to compile/run — AlertNotebookEndpoint.AuthoredTemplate returns null for both metrics (unregistered), confirmed by building the new test file alone against a detached origin/dev worktree.
  • GREEN on this branch: AlertNotebookTemplateQueryPlansTests (8/8), plus the shared theories AlertNotebookAuthoredTemplateTests, AlertNotebookEndpointTests, DocCommentHygieneTests — 162/162, 0 failed.
  • Darling.Tests.csproj and Lite.Tests.csproj both build 0 warnings-relevant/0 errors with -p:EnableWindowsTargeting=true. Both target net10.0-windows: they build here but cannot run on macOS; CI decides them.
  • Full suite not run (time budget); the targeted classes above plus both builds are the pins for this change.

CHANGELOG entry

SECTION: Added
ENTRY:

@erikdarlingdata
erikdarlingdata marked this pull request as ready for review September 26, 2026 13:43
@erikdarlingdata
erikdarlingdata merged commit 0dd9cfb into dev Sep 26, 2026
16 of 18 checks passed
@erikdarlingdata
erikdarlingdata deleted the fix/4223-notebook-long-query-forced-plan branch September 26, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant