Skip to content

*: remove deprecated RU v2 code - #71056

Merged
ti-chi-bot[bot] merged 7 commits into
pingcap:masterfrom
qw4990:ruv2_clean
Sep 15, 2026
Merged

ti-chi-bot[bot] merged 7 commits into
pingcap:masterfrom
qw4990:ruv2_clean

Conversation

@qw4990

@qw4990 qw4990 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #70747

Problem Summary: *: remove deprecated RU v2 code

What changed and how does it work?

Remove legacy RUv2 instrumentation, calculations, metrics, reporting paths, configuration, and obsolete tests. Preserve RUv3 accounting and the shared data collection it still requires.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Summary by CodeRabbit

  • Configuration

    • Removed legacy RU v2 weight settings from configuration examples.
    • RU v2 reporting mode remains available.
  • Behavior Changes

    • Removed RU v2 metrics from slow logs, runtime statistics, and monitoring.
    • RU v2 tracking now retains only TiKV coprocessor response bytes.
    • Removed RU v2 executor, parser, transaction, plan, DML, and cursor accounting.
  • Compatibility

    • RU v3 accounting and reporting remain unchanged.

@ti-chi-bot ti-chi-bot Bot added 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. sig/planner SIG: Planner labels Sep 14, 2026
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d4669931-f70b-4e2c-b41f-9e2cba64de1a

📥 Commits

Reviewing files that changed from the base of the PR and between 779f4b4 and 0cb0b5e.

📒 Files selected for processing (1)
  • pkg/server/conn_stmt.go

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

This change removes legacy RU v2 configuration, metrics, executor accounting, session propagation, cursor consumption reporting, and TopSQL sampling. RU v3 paths remain. TiKV coprocessor response bytes remain as the retained RU v2 metric.

Changes

RU v2 accounting removal

Layer / File(s) Summary
RU v2 contracts and runtime state
pkg/config/..., pkg/metrics/..., pkg/util/execdetails/..., pkg/distsql/..., pkg/sessionctx/...
Removes RU v2 weights, collectors, accounting fields, runtime-stat fields, and session state.
Execution instrumentation removal
pkg/executor/..., pkg/planner/..., pkg/session/..., pkg/util/topsql/...
Removes RU v2 executor IO accounting, row-column metrics, planner metrics, parser and transaction counters, slow-log propagation, and TopSQL RU v2 fields.
Cursor tracking simplification
pkg/server/...
Removes result-cell counting and resource-group consumption reporting. Cursor APIs now synchronize retained RU details with simpler signatures.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Other

Suggested reviewers: yangkeao

Merge Risk: ⚪ Minimal · up to 0cb0b

The change removes deprecated RU v2 accounting while preserving RU v3 charging and retained response-byte tracking; no concrete current-head failure was established.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.10% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 24 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing deprecated RU v2 code.
Description check ✅ Passed The description follows the required template. It includes the issue reference, problem summary, implementation summary, test checklist, side effects, documentation impact, and release note.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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

I’m a rabbit with tidy RU charts,
Snipping old weights into parts.
Bytes still hop through the TiKV night,
RU v3 keeps its steady light.
Cursors count less, and the burrow is bright.

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

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.20930% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.4578%. Comparing base (948f074) to head (9d35105).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #71056        +/-   ##
================================================
- Coverage   76.3180%   72.4578%   -3.8603%     
================================================
  Files          2041       2102        +61     
  Lines        556057     594884     +38827     
================================================
+ Hits         424372     431040      +6668     
- Misses       130785     162627     +31842     
- Partials        900       1217       +317     
Flag Coverage Δ
integration 40.7671% <37.2093%> (+1.0995%) ⬆️

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

Components Coverage Δ
dumpling 58.8716% <ø> (ø)
parser ∅ <ø> (∅)
br 46.5900% <ø> (-16.1209%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 15, 2026
@terry1purcell
terry1purcell requested a lite review from Copilot September 15, 2026 01:39

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

A critical configuration migration issue and a moderate TopRU behavior issue remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This pull request removes deprecated RU v2 accounting and instrumentation while retaining RU v3 response-byte collection.

Changes:

  • Removes RU v2 metrics, weights, calculations, and obsolete tests.
  • Simplifies RU tracking across executors, sessions, servers, and cursors.
  • Updates configuration, mocks, metrics, and Bazel dependencies.
File summaries
File Summary
pkg/util/topsql/stmtstats/stmtstats.go Removes RU v2 sampling. Moderate (1 vote): enabled TopRU can emit zero samples under RUVersionV2.
pkg/util/topsql/stmtstats/stmtstats_test.go Removes obsolete RU v2 TopSQL tests.
pkg/util/topsql/stmtstats/rustats.go Removes RU v2 statement statistics state.
pkg/util/topsql/stmtstats/BUILD.bazel Updates TopSQL build dependencies.
pkg/util/mock/context.go Removes deprecated RU v2 mock wiring.
pkg/util/execdetails/ruv2_metrics.go Retains response-byte collection needed by RU v3.
pkg/util/execdetails/runtime_stats.go Removes RU v2 runtime-stat accounting.
pkg/util/execdetails/execdetails_test.go Updates execution-detail tests.
pkg/util/execdetails/BUILD.bazel Updates execution-detail build inputs.
pkg/sessionctx/variable/tests/session_test.go Updates session-variable tests.
pkg/sessionctx/variable/tests/BUILD.bazel Updates session-variable test build configuration.
pkg/sessionctx/variable/slow_log.go Removes RU v2 slow-log reporting.
pkg/sessionctx/variable/session.go Removes RU v2 session configuration and accounting.
pkg/session/tidb.go Updates TiDB session integration.
pkg/session/tidb_test.go Updates TiDB session tests.
pkg/session/session.go Removes RU v2 session handling.
pkg/session/BUILD.bazel Updates session build dependencies.
pkg/server/internal/resultset/resultset.go Simplifies cursor RU tracking.
pkg/server/internal/resultset/cursor.go Removes obsolete cursor RU v2 accounting.
pkg/server/internal/resultset/BUILD.bazel Updates resultset build inputs.
pkg/server/driver_tidb.go Updates driver integration.
pkg/server/conn.go Reports cursor response-byte deltas.
pkg/server/conn_stmt.go Removes RU v2 statement handling.
pkg/server/conn_stmt_test.go Updates connection statement tests.
pkg/server/BUILD.bazel Updates server build dependencies.
pkg/planner/core/stats.go Removes RU v2 planner statistics.
pkg/planner/core/planbuilder.go Removes RU v2 plan accounting.
pkg/planner/core/casetest/indexmerge/indexmerge_test.go Removes obsolete index-merge coverage.
pkg/planner/core/casetest/indexmerge/BUILD.bazel Updates index-merge test build configuration.
pkg/metrics/ru_v2.go Removes deprecated RU v2 metrics.
pkg/metrics/metrics.go Updates metric registration.
pkg/metrics/metrics_internal_test.go Updates internal metric tests.
pkg/metrics/BUILD.bazel Updates metrics build dependencies.
pkg/executor/update.go Removes RU v2 update accounting.
pkg/executor/statement_ru_result_test.go Updates statement RU result tests.
pkg/executor/replace.go Removes RU v2 replace accounting.
pkg/executor/internal/exec/executor.go Removes executor RU v2 hooks.
pkg/executor/internal/exec/executor_test.go Updates executor tests.
pkg/executor/internal/exec/BUILD.bazel Updates executor build dependencies.
pkg/executor/insert.go Removes RU v2 insert accounting.
pkg/executor/insert_common.go Removes shared RU v2 insert handling.
pkg/executor/explain.go Removes RU v2 explain accounting.
pkg/executor/explain_unit_test.go Updates explain tests.
pkg/executor/delete.go Removes RU v2 delete accounting.
pkg/executor/BUILD.bazel Updates executor build configuration.
pkg/executor/adapter.go Retains final RU evidence collection.
pkg/executor/adapter_test.go Updates adapter tests.
pkg/executor/adapter_slow_log.go Removes RU v2 slow-log handling.
pkg/executor/adapter_internal_test.go Updates internal adapter tests.
pkg/distsql/context/context.go Retains response bytes and removes RU v2 context state.
pkg/distsql/context/context_test.go Updates distributed SQL context tests.
pkg/config/config.toml.example Removes RU v2 weights. Nit (1 vote): update the stale heading for statement RU v3.
pkg/config/config.go Removes RU v2 configuration. Critical (2 votes): add legacy keys to removedConfig and cover migration in tests.
pkg/config/config_test.go Updates configuration tests.
pkg/config/BUILD.bazel Updates configuration build dependencies.
Review details

Suppressed comments (2)

pkg/config/config.toml.example:441

  • The example section no longer contains RU v2 weights, but this heading still says it does. Users following the generated example will look for settings that no longer exist; update the heading to describe statement RU v3 reporting/weights.
# raw units by engine/opclass and calculation status for calibration.

pkg/util/topsql/stmtstats/stmtstats.go:248

  • When the domain reports RUVersionV2—the version used by the statement RU v3 path (pkg/executor/show_ddl_jobs.go:147-149)—this condition makes every TopRU sample zero. TopRU is still enabled by observeStmtBeginForTopProfiling and its reporter/subscription path remains active, so V2 deployments silently emit no TopRU records instead of reporting or rejecting the feature. Please either feed TopRU from the supported RU v3 total or explicitly disable/remove TopRU for this version; returning zero leaves an enabled API as a no-op.
  • Files reviewed: 55/55 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/config/config.go Outdated
Comment on lines 411 to 413
// Statement weights convert RU v3 raw work units to RU. They must be finite
// and non-negative; zero disables the corresponding charge. Their defaults
// are uncalibrated internal placeholders, not billing values.

@qw4990 qw4990 Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is expected, "RU-V2" has never been GA, so don't need to consider its compatibility.

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

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 15, 2026
@ti-chi-bot

ti-chi-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-09-15 01:22:06.894253222 +0000 UTC m=+81772.831910816: ☑️ agreed by windtalker.
  • 2026-09-15 01:57:45.158592783 +0000 UTC m=+83911.096250376: ☑️ agreed by yibin87.

@terry1purcell

Copy link
Copy Markdown
Contributor

/hold

Copilot review comment. You can remove the hold if you can either resolve the comment or determine that it is not relevant.

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 15, 2026

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

Pending removal of hold (which I am OK with if you confirm whether it is critical or not).

@ti-chi-bot

ti-chi-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: terry1purcell, windtalker, yibin87

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

The pull request process is described 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

@ti-chi-bot ti-chi-bot Bot added the approved label Sep 15, 2026
@qw4990

qw4990 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

/test check-dev2

@qw4990

qw4990 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 15, 2026
@qw4990

qw4990 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@ti-chi-bot
ti-chi-bot Bot merged commit 8bccb81 into pingcap:master Sep 15, 2026
34 checks passed
@qw4990 qw4990 mentioned this pull request Sep 15, 2026
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner 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.

5 participants