Skip to content

apicodec, resourcecontrol: decode StoreBatchCop response keys and settle batched task details (#2050, #2029) (tidb-8.5) - #2173

Merged
ti-chi-bot[bot] merged 2 commits into
tikv:tidb-8.5from
0xPoe:poe/tidb-8.5-pick-2050
Nov 16, 2026
Merged

ti-chi-bot[bot] merged 2 commits into
tikv:tidb-8.5from
0xPoe:poe/tidb-8.5-pick-2050

Conversation

@0xPoe

@0xPoe 0xPoe commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: ref pingcap/tidb#70665, ref pingcap/tidb#67449

Cherry-picks two fixes to tidb-8.5 for the TiDB release-8.5 backport of batched Analyze (pingcap/tidb#73139). One commit per source PR:

What is changed and how does it work?

Tests

  • go test ./internal/apicodec ./internal/resourcecontrol ./internal/locate -count=1: passes. Without the source changes, the new cases fail.

Summary by CodeRabbit

  • Bug Fixes
    • Response decoding now includes lock data and region errors from coprocessor and split-region responses, making this information available to callers.
    • Bucket-version mismatch boundaries are decoded and validated; malformed data now returns a decoding error instead of an unusable response.
    • Read-byte and KV CPU time totals now include data and processing from nested batched coprocessor responses.

ref pingcap/tidb#70665

(cherry picked from commit e490560)

Signed-off-by: 0xPoe <poe.liu@pm.me>
@ti-chi-bot ti-chi-bot Bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 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

API v2 response decoding now handles coprocessor batch and split-region errors and lock data. It decodes bucket-version mismatch boundary keys and returns errors for malformed keys. Response metrics now include read bytes and KV CPU time from nested coprocessor batch responses.

Changes: API v2 response decoding

Layer / File(s) Summary
Response decoding and validation
internal/apicodec/codec_v2.go, internal/apicodec/codec_v2_test.go, internal/apicodec/mem_codec.go, internal/locate/region_request.go
Coprocessor batch responses decode region errors and lock data. Split-region responses decode key errors. Bucket-version mismatch boundary keys are decoded, and malformed keys return decoding errors. Tests cover decoded fields, lock primary-key reuse in a transaction-status request, and malformed-key handling. Comments describe decode errors and boundary comparison.

Batched response metrics

Layer / File(s) Summary
Aggregate batched response metrics
internal/resourcecontrol/resource_control.go, internal/resourcecontrol/resource_control_test.go
MakeResponseInfo adds read bytes and KV CPU time from nested batch responses to the top-level totals. Tests cover processed-version sizes, data sizes, and processing times.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: jmpotato

Merge Risk: Minimal · up to 001c9

The change decodes API v2 batch and split-region response keys and aggregates nested batch metrics. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two areas changed (apicodec and resourcecontrol) and the two main changes: decoding StoreBatchCop response keys and settling batched task details. The summary confirms that codec_v…
Full details: Title check

Explanation

The title names the two areas changed (apicodec and resourcecontrol) and the two main changes: decoding StoreBatchCop response keys and settling batched task details. The summary confirms that codec_v2.go now decodes batched coprocessor RegionError, Locked, and BucketVersionNotMatch keys, and that MakeResponseInfo aggregates nested batch response read bytes and KV CPU time. The title is specific and matches the changeset. The cherry-pick references and the backport branch tag are noise but do 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: 9ad2a0cf-eac0-4e3c-ab55-7992af5c532a
Commits

Reviewing files that changed from the base of the PR and between cde6b9f and 001c9ce.

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; 0 remain after this review.

ref pingcap/tidb#67449

(cherry picked from commit 6667175)

Signed-off-by: 0xPoe <poe.liu@pm.me>
@0xPoe 0xPoe changed the title apicodec: decode StoreBatchCop response keys (#2050) (tidb-8.5) apicodec, resourcecontrol: cherry-pick #2050 and #2029 (tidb-8.5) Nov 13, 2026
@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 13, 2026
@0xPoe 0xPoe changed the title apicodec, resourcecontrol: cherry-pick #2050 and #2029 (tidb-8.5) apicodec, resourcecontrol: decode StoreBatchCop response keys and settle batched task details (#2050, #2029) (tidb-8.5) Nov 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

@qw4990: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

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.

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 16, 2026
@ti-chi-bot ti-chi-bot Bot added the lgtm label Nov 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, JmPotato, qw4990

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-11-16 13:10:09.925867605 +0000 UTC m=+1708934.551017890: ☑️ agreed by cfzjywxk.
  • 2026-11-16 13:56:19.141105808 +0000 UTC m=+1711703.766256099: ☑️ agreed by JmPotato.

@ti-chi-bot
ti-chi-bot Bot merged commit a99e02f into tikv:tidb-8.5 Nov 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants