Repository navigation
Top queries and procedures over long windows drop filters, report zeros for missing columns, and overstate coverage #4711
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When get_top_queries_by_cpu or get_top_procedures_by_cpu asks for a window longer than raw retention (about 72 hours and up), the read switches to the hourly rollup.
- That path ignores
parallel_only,min_dopandgroup_by=host_object, but the payload reports them as applied, and an empty page says the filter was applied in SQL. - Columns the rollup does not carry come back as 0 instead of null: reads, writes, physical reads, rows, spills, DOP and plan hash. The payload then shows
is_parallel=falseandavg_reads=0, although zero means "measured zero" everywhere else. min_cpu_msandmax_cpu_mson this path are the min and max of per-collection deltas, not the per-execution extremes the tool text promises.- Elapsed min/max and
sql_handleexist in the rollup, but the query reader doesn't select them. - Query text is looked up one row at a time with no time bound, and a miss returns empty text with no note.
- Coverage is reported as complete without checking where the rollup starts. A young store, or a young server on an older store, reports
window_truncated=falsefor a window the data doesn't cover. - The hourly predicate drops the partial hour at the window start and includes the whole hour at an
as_ofend.
Evidence (1248a67)
Paths under Darling/PerformanceMonitor.Darling.Service/Mcp/ unless noted:
DarlingMcpDataTools.cs:566-569,575-578,584-586,601-612,645-661,694-701; procedures754-756,769-773,795,810-814,822-823,837-841.DarlingDataReader.cs:1220-1254,1262-1271,1312-1329,1413-1442,1519-1524,1649.Darling/PerformanceMonitor.Darling.Storage/RetentionTierRouter.cs:68,210-260; rollup columns inTimescaleSupport.cs:2094-2098,9261,13510-13512.- The repo's rule:
DarlingMcpHostService.cs:990-992(a silently dropped knob is a confidently wrong answer). The live test docDarling.Tests/TopQueriesHourlyRoutingLiveTests.cs:180-185says the note should say the filter was NOT applied, but the test only checks that the note is non-empty.
Fix expected
- Filters: pass
minMaxDopandrollUpinto the router and force the raw tier when either is set (its floor probe already reportswindow_truncated). Refusing on the hourly tier doesn't work, because routing happens inside the reader. Makefilter_applied, thegroup_byecho and the empty-page text tier-aware. - Columns: null for reads, writes, physical reads, rows, spills, DOP and plan hash, and null
min/max_cpu_mson the hourly tier. Select elapsed min/max andsql_handle(the procedures reader already does).object_typeatDarlingMcpDataTools.cs:795is the in-file precedent. - Text: one
LEFT JOIN LATERALin the ranked statement (likeTopQueriesSql); null text plus a note when no raw row holds the hash. "Bounded by the raw floor" is a no-op. - Coverage: a per-server first-bucket probe over the same stitched relation, judged with
RawWindowFloor.IsTruncated(its 90-minute slack covers a first bucket up to an hour late). The store-wide floor alone misses the young-server case. - Edges: snap
effective_startto the first bucket and add a note on the trailing edge. The same predicate is used across the trend readers, so disclose rather than change one tool's predicate.
Tests that must fail before the fix
- An hourly-tier call with
min_dop: today it returns a rollup payload that claims the filter applied. - Missing columns are null, not 0, on the hourly tier.
- A server whose first bucket is after the window start reports
window_truncated=true.
Constraints
- Run the MCP census and pin tests (
McpPayloadContractCensusTests, the inventory pins).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
MCP top queries and procedures over long windows: no dropped filters,…
erikdarlingdata commentedon Sep 29, 2026
Claude posting for Erik Darling: fixed by #4715 (dceb4f1), merged to dev.
get_top_queries_by_cpuandget_top_procedures_by_cpuon the hourly rollup now keep raw-only filters on raw, return null for the columns the rollup lacks, look text up inside the ranked read, check coverage per server against the rollup's first bucket and its materialization ceiling, and disclose the hour edges. On the hourly tier, cpu_attribution uses the span the rollup served.