Skip to content

feat: add CN RSS pressure observability - #24538

Merged
mergify[bot] merged 3 commits into
matrixorigin:4.0-devfrom
LeftHandCold:obs/tpcc-cn-rss
May 26, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:4.0-devfrom
LeftHandCold:obs/tpcc-cn-rss

Conversation

@LeftHandCold

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:

Related to #24534

What this PR does / why we need it:

This PR adds lightweight observability for diagnosing CN RSS pressure during TPCC and similar high-concurrency workloads.

  1. Adds logtail replay retained batch histograms:
    • mo_logtail_replay_retained_batch_rows{type="insert|delete"}
    • mo_logtail_replay_retained_batch_bytes{type="insert|delete"}
  2. Adds LockOp batch hold histograms:
    • mo_txn_lock_op_batch_rows
    • mo_txn_lock_op_batch_bytes
    • mo_txn_lock_op_batch_hold_duration_seconds
  3. These metrics do not change execution semantics. The runtime overhead is limited to Prometheus histogram observations and one Batch.Size() call per non-empty LockOp batch / retained logtail replay batch.

Validation:

go test ./pkg/util/metric/v2 ./pkg/sql/colexec/lockop ./pkg/vm/engine/disttae/logtailreplay -run TestNonExistent -count=0

Add lightweight metrics for logtail replay retained batches and LockOp batch hold time so TPCC RSS pressure can be diagnosed without changing execution semantics.

Co-authored-by: Copilot <[email protected]>
@LeftHandCold
LeftHandCold requested a review from XuPeng-SH as a code owner May 22, 2026 06:30
Copilot AI review requested due to automatic review settings May 22, 2026 06:30
@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 →

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.

Pull request overview

Adds Prometheus histograms to improve observability into CN RSS pressure by quantifying (a) logtail replay “retained” row-entry batches and (b) LockOp batch size + time held during lock acquisition. This fits into the existing pkg/util/metric/v2 Prometheus registry and instruments two hot paths (logtailreplay and lockop) without changing execution behavior.

Changes:

  • Add mo_logtail_replay_retained_batch_{rows,bytes}{type=insert|delete} histograms and observe them when PartitionState retains row-entry batches.
  • Add mo_txn_lock_op_batch_{rows,bytes} and mo_txn_lock_op_batch_hold_duration_seconds histograms and observe them for non-empty LockOp batches.
  • Register the new metrics in the v2 metrics registry init functions.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/vm/engine/disttae/logtailreplay/partition_state.go Observe retained logtail replay batch row/byte histograms for insert/delete paths when !p.noData.
pkg/util/metric/v2/logtail.go Define logtail replay retained batch histogram vecs (rows/bytes) with type label.
pkg/util/metric/v2/txn.go Define txn LockOp batch rows/bytes and hold-duration histograms.
pkg/util/metric/v2/metrics.go Register the newly added logtail and txn metrics with the v2 registry.
pkg/sql/colexec/lockop/lock_op.go Instrument LockOp non-blocking path to observe batch size and hold duration around performLock.

Comment thread pkg/sql/colexec/lockop/lock_op.go Resolved
Use a single defer to record LockOp batch hold duration so the metric remains consistent across all return paths.

Co-authored-by: Copilot <[email protected]>

@aptend aptend 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.

LGTM. Clean observability PR.

  • Metrics are well-scoped: logtail replay retained batches + LockOp batch hold
  • No functional changes to execution semantics
  • Consistent bucketing with existing patterns
  • noData guard on partition_state avoids metric noise from ghost partitions
  • Runtime overhead limited to histogram observations and existing Batch.Size() call

@aunjgr aunjgr 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.

Review: CN RSS pressure observability

Approve.

This PR adds observability histograms/counters and registration wiring, plus lock-op/logtail replay metric observations, without changing transaction or lock semantics.

No blocking correctness or safety issue found.

@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.

Reviewed from multiple angles: metric registration/wiring, lockop control flow, logtail replay retention semantics, and potential init/observe/concurrency issues. The new histograms are correctly registered, the observations are guarded on the right paths (!p.noData for retained logtail batches, non-empty batches for lockop), and I don't see a correctness or regression risk from these observability-only changes. LGTM.

@mergify mergify Bot added the queued label May 26, 2026
@mergify

mergify Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-05-26 08:28 UTC · Rule: release-4.0
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-05-26 11:27 UTC · at 6b18312702a660f8ed251997556b38b7778b43d9 · squash

This pull request spent 2 hours 58 minutes 48 seconds in the queue, including 1 hour 46 minutes 23 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86

@mergify
mergify Bot merged commit edafe62 into matrixorigin:4.0-dev May 26, 2026
22 of 24 checks passed
@mergify mergify Bot removed the queued label May 26, 2026

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/enhancement size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants