Skip to content

Populate and refresh query runtime metrics matrices - #67

Merged
leborchuk merged 2 commits into
apache:mainfrom
leborchuk:fix/issue-42-runtime-matrix
Dec 2, 2026
Merged

leborchuk merged 2 commits into
apache:mainfrom
leborchuk:fix/issue-42-runtime-matrix

Conversation

@leborchuk

Copy link
Copy Markdown
Contributor

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

Fixes #42

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
@leborchuk
leborchuk requested review from tuhaihe and a balanced review from Copilot December 2, 2026 11:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread web/src/pages/QueryDetailPage.tsx Resolved

@tuhaihe tuhaihe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-metrics returned no cells for running queries.
  • With this PR, running aggregation queries return cells for slices 1-3 on segments 0-3.
  • A pg_sleep query whose QD title still read cmd1 while 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:

  1. Copilot's point about completed is 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. Adding completed to the matrix fetch deps would fix it.
  2. 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.
  3. 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.

@leborchuk

Copy link
Copy Markdown
Contributor Author

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-metrics returned no cells for running queries.
  • With this PR, running aggregation queries return cells for slices 1-3 on segments 0-3.
  • A pg_sleep query whose QD title still read cmd1 while 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:

  1. Copilot's point about completed is 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. Adding completed to the matrix fetch deps would fix it.
  2. 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.
  3. 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.

@leborchuk
leborchuk merged commit 9a33875 into apache:main Dec 2, 2026
3 checks passed
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.

[Bug] UI: runtime metrics matrix is empty for running queries

3 participants