Skip to content

session,store: remove RUv2 rpc interceptor#67508

Open
disksing wants to merge 2 commits intopingcap:masterfrom
oh-my-tidb:rpc-interceptor
Open

session,store: remove RUv2 rpc interceptor#67508
disksing wants to merge 2 commits intopingcap:masterfrom
oh-my-tidb:rpc-interceptor

Conversation

@disksing
Copy link
Copy Markdown
Contributor

@disksing disksing commented Apr 2, 2026

What problem does this PR solve?

Issue Number: ref #67199

Problem Summary:

TiDB currently relies on a dedicated RUv2 RPC interceptor to collect statement-level raw RPC counters. After kvproto exposes these counters on ExecDetailsV2.RuV2 and client-go starts filling them there, TiDB can remove the extra interceptor path and read the data directly from exec details.

What changed and how does it work?

  • update github.com/pingcap/kvproto to the latest master, including pingcap/kvproto#1445
  • update github.com/tikv/client-go/v2 to the latest master, including tikv/client-go#1933
  • remove TiDB-side RUv2 RPC interceptor wiring from DistSQL/session/txn setup
  • delete the old interceptor implementation and its tests
  • aggregate RUv2 raw counters directly from ExecDetailsV2.RuV2 into RUV2Metrics
  • keep the coprocessor collection path calling into the shared execdetails helper

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Summary by CodeRabbit

  • Chores
    • Bumped Go dependencies: golang.org/x/net (v0.50.0→v0.51.0) and updated several upstream module revisions.
  • Refactor
    • Consolidated and simplified RUv2 metrics collection, removing per-statement RPC interceptors and centralizing metric updates.
  • Tests
    • Added unit tests for centralized RUv2 metrics processing; removed several now-redundant interceptor-focused tests.

Signed-off-by: disksing <i@disksing.com>
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Apr 2, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0f158b9d-e522-4bbc-855f-0134951b883c

📥 Commits

Reviewing files that changed from the base of the PR and between e509742 and d2a0ea2.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod

📝 Walkthrough

Walkthrough

This PR bumps several Go dependency pins and removes statement-level RUv2 RPC interceptor metric plumbing, consolidating RUv2 metric updates into a new execdetails function and updating call sites and tests accordingly.

Changes

Cohort / File(s) Summary
Dependency updates
DEPS.bzl, go.mod
Bumped kvproto, tikv/client-go/v2, tikv/pd/client, and golang.org/x/net pins (pseudo-versions/sha256/strip_prefix/urls updated).
Removed interceptor implementation & tests
pkg/store/driver/txn/ruv2_metrics.go, pkg/store/driver/txn/ruv2_metrics_test.go, pkg/store/copr/ruv2_metrics.go, pkg/sessiontxn/isolation/base_test.go
Deleted files implementing statement-level tikvrpc interceptor.RPCInterceptor and their tests.
Removed interceptor wiring
pkg/distsql/context/context.go, pkg/distsql/distsql.go, pkg/session/session.go, pkg/sessiontxn/isolation/base.go, pkg/sessiontxn/staleread/provider.go, pkg/distsql/context/BUILD.bazel, pkg/session/BUILD.bazel, pkg/sessiontxn/isolation/BUILD.bazel, pkg/sessiontxn/staleread/BUILD.bazel
Removed RUV2RPCInterceptor field/usages, deleted WithRUV2MetricsInterceptor, and stopped attaching per-statement interceptors to txns/snapshots; corresponding BUILD deps adjusted.
Centralized execdetails logic & tests
pkg/util/execdetails/ruv2_metrics.go, pkg/util/execdetails/execdetails_test.go, pkg/util/execdetails/BUILD.bazel
Added UpdateRUV2MetricsFromExecDetailsV2(metrics, details) and tests; BUILD deps add kvrpcpb.
Coprocessor integration
pkg/store/copr/coprocessor.go, pkg/store/copr/BUILD.bazel
Replaced inline copr exec-details update with context-based RUV2MetricsFromContext + UpdateRUV2MetricsFromExecDetailsV2; removed ruv2_metrics.go from copr sources.
Misc tests/build adjustments
pkg/distsql/context/context_test.go, pkg/session/tidb_test.go, pkg/store/driver/txn/BUILD.bazel
Removed interceptor-related test assertions/imports, adjusted BUILD srcs/deps and test shard counts.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Session
participant DistSQL
participant TxnDriver as Txn/Store Driver
participant TiKV
participant Copr as Coprocessor
participant ExecDetails as execdetails.UpdateRUV2MetricsFromExecDetailsV2

Note over Session,TiKV: Old flow (interceptor-based)
Session->>DistSQL: create request (with RUV2RPCInterceptor)
DistSQL->>TxnDriver: send RPC (wrapped by interceptor)
TxnDriver->>TiKV: RPC call
TiKV-->>TxnDriver: response + ExecDetailsV2
TxnDriver->>TxnDriver: interceptor observes response
TxnDriver->>Session: interceptor updates RUV2 metrics on stored metrics instance

Note over Session,TiKV: New flow (centralized)
Session->>DistSQL: create request (no statement interceptor)
DistSQL->>TxnDriver: send RPC
TxnDriver->>TiKV: RPC call
TiKV-->>TxnDriver: response + ExecDetailsV2
TxnDriver->>Copr: coprocessor handler receives response
Copr->>ExecDetails: call UpdateRUV2MetricsFromExecDetailsV2(RUV2MetricsFromContext(ctx), ExecDetailsV2)
ExecDetails-->Copr: metrics updated centrally

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

type/refactor

Suggested reviewers

  • XuHuaiyu
  • hawkingrei

Poem

🐰
I hopped through RPCs with a tiny hat,
Counting hops on network and chat.
Now metrics sit snug in one tidy nest,
Execdetails does the tallying best—
Hooray, fewer hops, more time to nap! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'session,store: remove RUv2 rpc interceptor' clearly and concisely summarizes the main change—removal of the RUv2 RPC interceptor from the session and store packages.
Description check ✅ Passed The PR description provides a clear problem statement, explains what changed, includes the referenced issue number, confirms unit tests were added, and follows the repository's template structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ti-chi-bot ti-chi-bot bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 2, 2026
@tiprow
Copy link
Copy Markdown

tiprow bot commented Apr 2, 2026

Hi @disksing. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@disksing disksing marked this pull request as ready for review April 2, 2026 06:52
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 2, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai bot commented Apr 2, 2026

Review Complete

Findings: 0 issues
Posted: 0
Duplicates/Skipped: 0

ℹ️ Learn more details on Pantheon AI.

@disksing
Copy link
Copy Markdown
Contributor Author

disksing commented Apr 2, 2026

/retest

@disksing
Copy link
Copy Markdown
Contributor Author

disksing commented Apr 2, 2026

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Apr 2, 2026
Copy link
Copy Markdown

@pantheon-ai pantheon-ai bot left a comment

Choose a reason for hiding this comment

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

✅ Code looks good. No issues found.

@disksing
Copy link
Copy Markdown
Contributor Author

disksing commented Apr 2, 2026

/retest

1 similar comment
@disksing
Copy link
Copy Markdown
Contributor Author

disksing commented Apr 2, 2026

/retest

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.0594%. Comparing base (8412422) to head (d2a0ea2).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67508        +/-   ##
================================================
- Coverage   77.7173%   77.0594%   -0.6580%     
================================================
  Files          1959       1943        -16     
  Lines        543377     543617       +240     
================================================
- Hits         422298     418908      -3390     
- Misses       120238     124707      +4469     
+ Partials        841          2       -839     
Flag Coverage Δ
integration 40.9274% <11.3207%> (+4.7526%) ⬆️
unit 76.1713% <100.0000%> (-0.1718%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 61.5065% <ø> (ø)
parser ∅ <ø> (∅)
br 48.7225% <ø> (-12.2576%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@disksing
Copy link
Copy Markdown
Contributor Author

disksing commented Apr 2, 2026

/retest

Signed-off-by: disksing <i@disksing.com>
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Apr 3, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bb7133, benjamin2037 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@disksing
Copy link
Copy Markdown
Contributor Author

disksing commented Apr 3, 2026

/retest

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Apr 3, 2026

@disksing: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test d2a0ea2 link true /test unit-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant