Repository navigation
Populate and refresh query runtime metrics matrices - #67
Conversation
Correlate a one-step coordinator process-title command lag only with an active collector query on the same backend. Preserve exact, executor, idle, unknown and unrelated identities; use coordinator slice zero when no explicit slice is available. Align process discovery with enabled procfs sampling, poll active query metrics without overlapping requests, and refresh selected-cell details. Stop polling on completion or navigation and document sampling limitations. Fixes apache#42
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues can misattribute metrics to a subsequent command and leave the query-detail matrix stale or empty when polling stops.
2 open issues
What changed in this PR
Addresses #42 by aligning coordinator process samples with query identities and periodically refreshing runtime metrics in the query detail UI.
Changes:
- Reconciles coordinator command counts and defaults coordinator samples to slice 0.
- Adds five-second polling and keeps selected-cell metrics current.
- Aligns process discovery cadence with sampling and documents the behavior.
| File | Description |
|---|---|
| web/src/pages/QueryDetailPage.tsx | Refreshes query status and runtime metrics. |
| web/src/hooks/useApi.ts | Adds optional polling. |
| internal/utils/procfs.go | Defaults coordinator samples to slice 0. |
| internal/utils/procfs_getprocinfo_test.go | Tests coordinator slice handling. |
| internal/coordinator/procfs_query_identity.go | Reconciles lagging coordinator command counts. |
| internal/coordinator/procfs_query_identity_test.go | Tests query identity reconciliation guards. |
| internal/coordinator/background.go | Applies reconciliation before storing samples. |
| internal/app/app.go | Aligns process discovery with sampling cadence. |
| docs/proc-stats-flow.md | Documents process discovery cadence. |
| docs/performance-tuning.md | Explains polling and sampling limitations. |
| docs/API.md | Documents reconciled command counts. |
Review effort: Balanced
tuhaihe
left a comment
There was a problem hiding this comment.
LGTM, thanks. I tested this on a sandbox cluster (1 coordinator + 2 segment hosts, gp_stats_collector enabled), using a build of 8c564a5 with the embedded UI:
- With main,
/api/query/{ssid}/{ccnt}/running-metricsreturned no cells for running queries. - With this PR, running aggregation queries return cells for slices 1-3 on segments 0-3.
- A
pg_sleepquery whose QD title still readcmd1while the collector reported ccnt=2 now shows its coordinator cell (slice 0, segindex -1). That confirms the one-step lag correction works. - CI is green.
A few non-blocking follow-ups:
- Copilot's point about
completedis valid. When the detail page detects that the query has finished, the matrix stops polling without a final fetch, so it can stay on stale or empty data until the page is reloaded. Addingcompletedto the matrix fetch deps would fix it. - Every poll sets
loading=true, and both the page and the matrix are wrapped in<Spin spinning={loading}>. The whole page dims every 5s while a query runs. Showing the spinner only on the first load (loading && !data) would avoid the flicker. - The ccnt-reconciliation race Copilot raised (command N sampled, then N+1 starts before correlation) is a narrow window and only mislabels one sample, so I'm fine leaving it as is.
Note: the two Copilot threads need to be resolved before this can be merged, because required_conversation_resolution is enabled.
Thank you, make sense, fixed it. |

Command counter could differ on master and on segment. Align them and use in procfs data to show stat
Fixes #42