Skip to content

metric: add CI timeout observability - #25178

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:violet/observe-ci-timeout-metrics
Jul 13, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:violet/observe-ci-timeout-metrics

Conversation

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #25074
issue #25164

What this PR does / why we need it:

This PR adds observability for CI/sysbench failures where clients see proxy all-CN-busy errors or backend/RPC timeout errors.

In simpler terms, it adds gauges/counters/dashboards that answer:

  • Are CN/DN pods already near memory or CPU limits?
  • Did the DN merge scheduler pause because available memory was too low?
  • Did proxy mark specific CNs unhealthy, and did all candidate CNs become busy?
  • Are proxy-to-CN handshakes slow or piling up?
  • Did MORPC/lockservice fail on connect/read/write/wait-response, and what error type was it?

Changes:

  • Add DN merge OOM governor metrics.
  • Add proxy CN health, backend handshake latency, and in-flight handshake metrics.
  • Add MORPC backend error and lockservice remote RPC error metrics with low-cardinality labels.
  • Add Grafana panels for pod resources, merge OOM governor, proxy health/handshake, and RPC timeout/backend errors.
  • Add an observability runbook with PromQL/LogQL queries for CI regression investigations.
  • Add focused tests for MORPC and lockservice error type classification.

This PR does not claim to fix the sysbench overload root cause. It makes the failure chain observable so future 20508/20505 failures can be diagnosed from metrics instead of only from logs.

Validation:

  • git diff --check
  • go test ./pkg/proxy
  • go test ./pkg/vm/engine/tae/db/merge
  • go test ./pkg/common/morpc
  • go test ./pkg/common/morpc ./pkg/lockservice -run 'TestRPCMetricErrorType|TestLockserviceRemoteRPCErrorType'
  • go test ./pkg/util/metric/v2 ./pkg/util/metric/v2/dashboard -run 'TestDoesNotExist'

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Superseding my earlier approve: I found two blockers.

  1. pkg/common/morpc/backend.go:999-1006 + pkg/common/morpc/metrics.go:86-123

    • The new MORPC metric is recorded on the raw dial/connect error before that error is wrapped as moerr.ErrBackendCannotConnect. For common hard failures like ECONNREFUSED / DNS / no-route, rpcMetricErrorType() therefore falls through to other instead of backend_cannot_connect, which defeats the stated goal of distinguishing backend-connect failures.
    • Suggested fix: classify after wrapping, or map non-timeout dial/net errors to backend_cannot_connect inside rpcMetricErrorType().
  2. pkg/proxy/cn_health.go:255,292,307,409, pkg/proxy/router.go:391-397, pkg/util/metric/v2/proxy.go:118-141

    • The new proxy metrics key counters/histograms/gauges by raw cn_uuid, but there is no corresponding metric-label delete path when CNs churn out of the cluster. sweepStale() only cleans the in-memory breaker map; it does not reclaim metric series. That makes series cardinality grow with cumulative CN churn, not current cluster size.
    • Suggested fix: avoid raw cn_uuid as a metric label here (aggregate by event/result only, or use a bounded dimension), or add an explicit label-lifecycle delete path when CNs leave.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Addressed the change request in e814fdf.

Changes:

  • MORPC connect errors are now recorded after classification: timeout dial retries are still counted as timeout, while non-retryable connect failures are wrapped as ErrBackendCannotConnect before recording, so they classify as backend_cannot_connect instead of other.
  • Removed raw cn_uuid from the new proxy Prometheus metrics to avoid cumulative CN churn cardinality:
    • mo_proxy_cn_health_total{event}
    • mo_proxy_backend_handshake_duration_seconds{result}
    • mo_proxy_backend_handshake_inflight
  • Updated proxy dashboard queries and the observability runbook to match the reduced labels.
  • Added a MORPC classification test for ErrBackendCannotConnect wrapping a net error.

Validation:

  • git diff --check
  • go test ./pkg/common/morpc ./pkg/lockservice -run 'TestRPCMetricErrorType|TestLockserviceRemoteRPCErrorType'
  • go test ./pkg/common/morpc
  • go test ./pkg/proxy
  • go test ./pkg/util/metric/v2 ./pkg/util/metric/v2/dashboard -run 'TestDoesNotExist'

@XuPeng-SH
XuPeng-SH merged commit 3728f38 into matrixorigin:main Jul 13, 2026
1 of 4 checks passed

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/documentation Improvements or additions to documentation kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants