Skip to content

resourcecontrol: settle batched cop tasks' execution details (#2029) (tidb-8.5) - #2174

Closed
0xPoe wants to merge 1 commit into
tikv:tidb-8.5from
0xPoe:poe/tidb-8.5-pick-2029
Closed

0xPoe wants to merge 1 commit into
tikv:tidb-8.5from
0xPoe:poe/tidb-8.5-pick-2029

Conversation

@0xPoe

@0xPoe 0xPoe commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: ref pingcap/tidb#67449

Cherry-pick of #2029 to tidb-8.5. The TiDB release-8.5 backport of batched Analyze (pingcap/tidb#73139) sends store-batched coprocessor requests. Without this change, resource control charges only the main task of each batch, because the execution details of the other tasks are in the nested batch responses.

What is changed and how does it work?

Same change as #2029: MakeResponseInfo adds the read bytes and KV CPU of every nested batch response. tidb-8.5 has no NextGen read-byte rule and its kvproto has no TotalVersionsSize, so the nested responses use ProcessedVersionsSize, as the top-level response already does there.

Tests

  • go test ./internal/resourcecontrol/ -count=1: passes. Without the resource_control.go change, TestResponseInfoBatchedTasks fails (80 read bytes instead of 118, 1µs KV CPU instead of 1.3µs).

Summary by CodeRabbit

  • Bug Fixes
    • Resource usage metrics now include read bytes and KV CPU time from nested responses in batched operations.

ref pingcap/tidb#67449

(cherry picked from commit 6667175)

Signed-off-by: 0xPoe <poe.liu@pm.me>
@ti-chi-bot

ti-chi-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

[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 sunxiaoguang 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

@ti-chi-bot ti-chi-bot Bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

MakeResponseInfo now includes nested coprocessor response data sizes and KV CPU time in its returned totals. A new test checks the combined top-level and nested metrics.

Changes: Batch response metrics

Layer / File(s) Summary
Nested response metric aggregation
internal/resourcecontrol/resource_control.go, internal/resourcecontrol/resource_control_test.go
MakeResponseInfo adds nested response data sizes and KV CPU time to the top-level totals. The test checks read-byte and CPU totals across top-level and nested responses.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: jmpotato, cabinfeverb

Merge Risk: Minimal · up to 7f6be

This change makes resource control charge for all tasks in store-batched coprocessor responses. It is a small, localized fix with a covering test, and no merge-blocking risk is apparent.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the resourcecontrol package and says batched coprocessor tasks' execution details are settled, which matches the change. MakeResponseInfo now adds read bytes and KV CPU from every nest…
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.
Full details: Title check

Explanation

The title names the resourcecontrol package and says batched coprocessor tasks' execution details are settled, which matches the change. MakeResponseInfo now adds read bytes and KV CPU from every nested batch response, and the new test covers it. The title is specific and related to the main change. The '(#2029) (tidb-8.5)' suffix is a cherry-pick reference and does not describe the code change, but it does not make the title misleading.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dda07932-1f6d-46b1-8576-092d03ff4679
Commits

Reviewing files that changed from the base of the PR and between 3f9d5b4 and 7f6bef3.

Files selected for processing: 2

  • internal/resourcecontrol/resource_control.go
  • internal/resourcecontrol/resource_control_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@0xPoe

0xPoe commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Merged into #2173, which now carries both picks.

@0xPoe 0xPoe closed this Nov 13, 2026
@0xPoe
0xPoe deleted the poe/tidb-8.5-pick-2029 branch November 13, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the dco. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant