Skip to content

*: fix gRPC request source fields#68301

Open
ekexium wants to merge 1 commit into
pingcap:masterfrom
ekexium:fix-missing-request-source
Open

*: fix gRPC request source fields#68301
ekexium wants to merge 1 commit into
pingcap:masterfrom
ekexium:fix-missing-request-source

Conversation

@ekexium
Copy link
Copy Markdown
Member

@ekexium ekexium commented May 11, 2026

What problem does this PR solve?

Issue Number: ref #33963

Problem Summary:

Fix some missing grpc request source fields

What changed and how does it work?

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

  • Chores
    • Standardized and expanded request-source tagging across restore, import, snapshot, GC, DDL, Lightning, and storage paths to improve observability and diagnostics for internal TiKV operations.
    • Updated tests and build metadata to include the new request-source utility dependency.

Review Change Stack

Copilot AI review requested due to automatic review settings May 11, 2026 11:56
@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label May 11, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented May 11, 2026

@ekexium I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 11, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 11, 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 gmhdbjd, leavrth 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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 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: 1332e969-33a4-445f-bc6b-08ba46f01e3e

📥 Commits

Reviewing files that changed from the base of the PR and between b5d0f47 and 3f7d233.

📒 Files selected for processing (15)
  • br/pkg/restore/log_client/client.go
  • br/pkg/restore/log_client/import.go
  • br/pkg/restore/snap_client/client.go
  • br/pkg/restore/snap_client/placement_rule_manager.go
  • br/pkg/restore/snap_client/tikv_sender.go
  • br/pkg/restore/split/client.go
  • br/tests/br_key_locked/BUILD.bazel
  • br/tests/br_key_locked/locker.go
  • pkg/ddl/cluster.go
  • pkg/lightning/backend/local/local.go
  • pkg/store/copr/batch_coprocessor.go
  • pkg/store/driver/tikv_driver.go
  • pkg/store/gcworker/gc_worker.go
  • pkg/store/helper/BUILD.bazel
  • pkg/store/helper/helper.go
✅ Files skipped from review due to trivial changes (3)
  • br/tests/br_key_locked/BUILD.bazel
  • pkg/store/helper/BUILD.bazel
  • pkg/lightning/backend/local/local.go
🚧 Files skipped from review as they are similar to previous changes (12)
  • br/pkg/restore/snap_client/client.go
  • pkg/store/driver/tikv_driver.go
  • pkg/store/copr/batch_coprocessor.go
  • br/pkg/restore/log_client/client.go
  • br/pkg/restore/split/client.go
  • br/pkg/restore/snap_client/placement_rule_manager.go
  • pkg/store/helper/helper.go
  • pkg/ddl/cluster.go
  • br/tests/br_key_locked/locker.go
  • pkg/store/gcworker/gc_worker.go
  • br/pkg/restore/snap_client/tikv_sender.go
  • br/pkg/restore/log_client/import.go

📝 Walkthrough

Walkthrough

Adds a new split client WithRequestSource option and populates kvrpcpb.Context.RequestSource for split-region and many TiKV RPCs across BR, Lightning, DDL, GC, MVCC helpers, storage paths, and tests.

Changes

Add RequestSource Metadata to TiKV RPC Requests

Layer / File(s) Summary
Split client RequestSource option
br/pkg/restore/split/client.go
Adds WithRequestSource exported option, stores requestSource in pdClient, extends splitRegionWithFailpoint to accept requestSource, and passes it from sendSplitRegionRequest.
BR: log & snapshot clients
br/pkg/restore/log_client/client.go, br/pkg/restore/log_client/import.go, br/pkg/restore/snap_client/client.go, br/pkg/restore/snap_client/placement_rule_manager.go, br/pkg/restore/snap_client/tikv_sender.go
Wires split.WithRequestSource(kvutil.BuildRequestSource(...)) into split clients created by LogClient and SnapClient; adds RequestSource to import/apply RPC contexts and necessary kvutil/kv imports.
TiDB subsystems and storage paths
pkg/ddl/cluster.go, pkg/lightning/backend/local/local.go, pkg/store/copr/batch_coprocessor.go, pkg/store/driver/tikv_driver.go, pkg/store/gcworker/gc_worker.go, pkg/store/helper/helper.go, pkg/store/helper/BUILD.bazel
Sets kvrpcpb.Context.RequestSource for DDL flashback RPCs, Lightning split client, batch coprocessor requests, lock-waits, unsafe-destroy/GC requests, and MVCC helper requests; updates imports and BUILD deps for tikv client-go/v2/util.
Tests and BUILD deps
br/tests/br_key_locked/locker.go, br/tests/br_key_locked/BUILD.bazel
Adds kvutil import and BUILD dep; updates test prewrite requests to include RequestSource.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • pingcap/tidb#66795: Modifies TiKV request-source handling and explicit request-type variants.
  • pingcap/tidb#66065: Touches br/pkg/restore/split/client.go and split client behavior related to options/signature changes.

Suggested labels

ok-to-test, approved, lgtm

Suggested reviewers

  • wjhuang2016
  • YuJuncen
  • D3Hunter
  • cfzjywxk
  • joechenrh

Poem

🐰 I hop through code both wide and deep,
Tagging requests so callers keep,
From split to GC, Lightning's light,
Each RPC now wears its sight,
A tiny hop for observability's leap.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. 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 '*: fix gRPC request source fields' is concise and clearly summarizes the main change—adding missing request source fields to gRPC requests across multiple packages.
Description check ✅ Passed The description includes the required Issue Number (ref #33963) and Problem Summary, but lacks detailed explanation of what changed and how it works.
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.

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

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Command failed


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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves request attribution/diagnostics by ensuring various internal TiDB/BR/Lightning/DDL/GC TiKV gRPC requests consistently populate kvrpcpb.Context.RequestSource, aligning with issue #33963’s goal of distinguishing internal vs external workload.

Changes:

  • Add RequestSource to multiple internal TiKV RPCs (GC, DDL flashback, MVCC helper, lock-wait info, TiFlash batch cop).
  • Plumb a configurable request source through BR’s region split client and set it from BR/Lightning call sites.
  • Set request source on BR test utilities and Lightning local backend split client creation.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/store/helper/helper.go Sets RequestSource for MVCC helper RPCs (MvccGetByKey, MvccGetByStartTs).
pkg/store/gcworker/gc_worker.go Sets RequestSource for GC and unsafe destroy range requests.
pkg/store/driver/tikv_driver.go Sets RequestSource for CmdLockWaitInfo requests.
pkg/store/copr/batch_coprocessor.go Propagates request source into TiFlash batch cop requests.
pkg/lightning/backend/local/local.go Sets request source on the BR split client used by Lightning local backend.
pkg/ddl/cluster.go Sets RequestSource for flashback prepare/execute RPCs.
br/tests/br_key_locked/locker.go Tags BR test prewrite requests with BR request source.
br/pkg/restore/split/client.go Adds optional request-source plumbing into split client and attaches it to SplitRegion RPC context.
br/pkg/restore/snap_client/tikv_sender.go Configures split client request source for BR restore splitting.
br/pkg/restore/snap_client/placement_rule_manager.go Configures split client request source used by placement rule manager tooling.
br/pkg/restore/snap_client/client.go Configures split client request source during restore client initialization.
br/pkg/restore/log_client/import.go Sets RequestSource in ApplyKVFile request context.
br/pkg/restore/log_client/client.go Configures split clients with BR request source in log restore flows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 55.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.6994%. Comparing base (84d8269) to head (3f7d233).
⚠️ Report is 26 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #68301        +/-   ##
================================================
+ Coverage   77.7288%   78.6994%   +0.9706%     
================================================
  Files          1990       2003        +13     
  Lines        551970     560230      +8260     
================================================
+ Hits         429040     440898     +11858     
+ Misses       122010     117240      -4770     
- Partials        920       2092      +1172     
Flag Coverage Δ
integration 46.9673% <55.0000%> (+7.1655%) ⬆️

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

Components Coverage Δ
dumpling 60.4888% <ø> (ø)
parser ∅ <ø> (∅)
br 65.8612% <94.7368%> (+2.7677%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ekexium ekexium force-pushed the fix-missing-request-source branch from b5d0f47 to 3f7d233 Compare May 12, 2026 09:59
@ekexium
Copy link
Copy Markdown
Member Author

ekexium commented May 12, 2026

/retest

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 12, 2026

@ekexium: 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
pull-unit-test-ddlv1 3f7d233 link true /test pull-unit-test-ddlv1

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

release-note-none Denotes a PR that doesn't merit a release note. 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.

2 participants