Skip to content

store: mark TiDB requests for max-ts validation - #68779

Merged
ti-chi-bot[bot] merged 6 commits into
pingcap:masterfrom
ekexium:codex/max-ts-request-origin-tidb
Jun 3, 2026
Merged

store: mark TiDB requests for max-ts validation#68779
ti-chi-bot[bot] merged 6 commits into
pingcap:masterfrom
ekexium:codex/max-ts-request-origin-tidb

Conversation

@ekexium

@ekexium ekexium commented May 29, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: close #68799

Problem Summary:

TiKV needs to distinguish TiDB-originated requests from other client-go users so selected non-TiDB max-ts update paths can be validated without drift tolerance.

What changed and how does it work?

  • Set the client-go process default request origin to REQUEST_ORIGIN_TIDB from cmd/tidb-server.
  • Extend TestRequestSource to verify TiDB requests carry kvrpcpb.Context.request_origin on the wire.
  • Temporarily reference the stacked kvproto/client-go draft PRs through fork replace directives so this draft can compile before upstream dependency PRs merge.

The temporary dependency replaces should be removed after pingcap/kvproto#1479 and tikv/client-go#1975 are merged and TiDB can bump normal upstream module versions.

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.

Commands:

  • make bazel_prepare
  • GOPRIVATE=github.com/ekexium/kvproto,github.com/ekexium/client-go ./tools/check/failpoint-go-test.sh pkg/session/test -run TestRequestSource
  • GOPRIVATE=github.com/ekexium/kvproto,github.com/ekexium/client-go gotestsum --format short-verbose -- ./cmd/tidb-server -run '^$'
  • GOPRIVATE=github.com/ekexium/kvproto,github.com/ekexium/client-go make lint
  • git diff --check

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

    • Updated TiKV client RPC dependencies and set a default TiKV RPC request origin used during server startup.
  • Tests

    • Expanded tests to validate TiKV request origin across additional read and write request paths, ensuring requests carry the expected origin.

@ti-chi-bot

ti-chi-bot Bot commented May 29, 2026

Copy link
Copy Markdown

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/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-triage-completed labels May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Review Change Stack

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: 8405ab1b-8aad-4cb1-8657-9ae5cddfa33e

📥 Commits

Reviewing files that changed from the base of the PR and between 4e49f39 and 9e54cb3.

📒 Files selected for processing (1)
  • cmd/tidb-server/main.go

📝 Walkthrough

Walkthrough

The PR marks TiDB-originated TiKV requests as RequestOriginTiDB: Bazel deps added, server startup sets the default request origin, and tests assert the origin is present across several RPC request types.

Changes

Request Origin Identification

Layer / File(s) Summary
Build configuration for TiKV request origin
cmd/tidb-server/BUILD.bazel
Bazel target tidb-server_lib deps list updated with TiKV RPC dependencies (@com_github_pingcap_kvproto//pkg/kvrpcpb, @com_github_tikv_client_go_v2//tikvrpc).
Request origin propagation test
pkg/session/test/session_test.go
TestRequestSource sets the default request origin to RequestOriginTiDB for the test and asserts requestOrigin == RequestOriginTiDB alongside existing requestSource checks for Prewrite, Commit, Coprocessor, Get, BatchGet, and PessimisticLock request types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through TiKV's door,
Marking requests—"From TiDB, not more!"
Tests listen close for origin's cheer,
Build links added so it’s crystal clear,
Hooray—requests now wear their badge sincere.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 'store: mark TiDB requests for max-ts validation' clearly summarizes the main change: marking TiDB requests with request origin for max-ts validation purposes.
Description check ✅ Passed The PR description follows the template with Issue Number linked (#68799), clear Problem Summary explaining TiKV needs to distinguish TiDB requests, detailed What changed section, completed Check List with unit and manual tests, and proper test commands provided.
Linked Issues check ✅ Passed The PR changes directly address issue #68799 objectives: setting REQUEST_ORIGIN_TIDB marking in tidb-server for client-go, extending TestRequestSource to verify request origin on the wire, enabling TiKV to differentiate TiDB from non-TiDB requests for max-ts validation.
Out of Scope Changes check ✅ Passed All changes are within scope: BUILD.bazel updates add necessary dependencies, main.go sets request origin as required, TestRequestSource validates the marking on the wire. No unrelated modifications detected.

✏️ 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 May 29, 2026
@tiprow

tiprow Bot commented May 29, 2026

Copy link
Copy Markdown

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

@ekexium
ekexium force-pushed the codex/max-ts-request-origin-tidb branch from 07f1963 to f2ec167 Compare May 29, 2026 15:46
@ekexium
ekexium force-pushed the codex/max-ts-request-origin-tidb branch from f2ec167 to 0bf1fe0 Compare May 30, 2026 01:35
@ekexium
ekexium force-pushed the codex/max-ts-request-origin-tidb branch 2 times, most recently from 3003007 to 145967c Compare May 30, 2026 02:32
Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ekexium
ekexium force-pushed the codex/max-ts-request-origin-tidb branch from 145967c to bc2bc07 Compare May 30, 2026 02:40
Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 1, 2026
Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 1, 2026
@ekexium
ekexium marked this pull request as ready for review June 1, 2026 10:13
Copilot AI review requested due to automatic review settings June 1, 2026 10:13
@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 Jun 1, 2026
@pantheon-ai

pantheon-ai Bot commented Jun 1, 2026

Copy link
Copy Markdown

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

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.

Pull request overview

This PR marks TiDB-originated TiKV requests by setting a process-wide default kvrpcpb.Context.request_origin to RequestOriginTiDB, and extends an existing unit test to assert the origin is carried on the wire. It also bumps kvproto and client-go versions (and the Bazel deps metadata) to pick up the required proto/client changes.

Changes:

  • Set tikvrpc process default request origin to RequestOriginTiDB in tidb-server.
  • Extend TestRequestSource to assert request_origin is set for various RPC types.
  • Bump github.com/pingcap/kvproto and github.com/tikv/client-go/v2 versions (Go modules + Bazel go_repository).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/session/test/session_test.go Extends request-source test to also validate request_origin propagation; sets/reset default origin within the test.
cmd/tidb-server/main.go Sets the process default TiKV request origin to TiDB at startup.
cmd/tidb-server/BUILD.bazel Adds Bazel deps for new imports (kvrpcpb, tikvrpc).
go.mod Bumps kvproto and client-go module versions.
go.sum Updates sums for the bumped kvproto and client-go versions.
DEPS.bzl Updates Bazel go_repository pins (strip_prefix/sha256/urls) for kvproto and client-go.

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

Comment thread go.mod
Comment thread go.mod

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@go.mod`:
- Line 104: The go.mod references a non-resolvable pseudo-version for
github.com/tikv/client-go/v2 (v2.0.8-0.20260601085006-f2ffb0f83e51) which causes
module fetches to 404; fix it by either replacing that pseudo-version with a
proxy-resolvable tag (bump to an official v2.x release) or add an explicit
replace directive for github.com/tikv/client-go/v2 pointing to the correct
fork/commit URL that contains commit f2ffb0f83e51 so go list/go build can fetch
it; update the go.mod entry for github.com/tikv/client-go/v2 accordingly and run
go mod tidy to validate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: daf611b9-2fde-4823-91b4-c388d5345f15

📥 Commits

Reviewing files that changed from the base of the PR and between 1c3f9eb and af6ba2e.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • DEPS.bzl
  • cmd/tidb-server/BUILD.bazel
  • cmd/tidb-server/main.go
  • go.mod
  • pkg/session/test/session_test.go

Comment thread go.mod
@ekexium

ekexium commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

/retest

@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.1788%. Comparing base (c1faae7) to head (9e54cb3).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #68779        +/-   ##
================================================
- Coverage   76.3157%   75.1788%   -1.1370%     
================================================
  Files          2041       2026        -15     
  Lines        562986     568454      +5468     
================================================
- Hits         429647     427357      -2290     
- Misses       132425     141050      +8625     
+ Partials        914         47       -867     
Flag Coverage Δ
integration 41.2528% <ø> (+1.5254%) ⬆️

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

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

@ekexium

ekexium commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

/retest

@ekexium
ekexium requested review from MyonKeminta and zyguan June 1, 2026 13:00
@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 2, 2026
@ekexium
ekexium requested a review from cfzjywxk June 3, 2026 07:39
@ti-chi-bot

ti-chi-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, zyguan

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 lgtm approved and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-02 02:46:22.965615399 +0000 UTC m=+236884.035932789: ☑️ agreed by zyguan.
  • 2026-06-03 08:16:56.274980393 +0000 UTC m=+343117.345297783: ☑️ agreed by cfzjywxk.

…quest-origin-tidb

# Conflicts:
#	DEPS.bzl
#	go.mod
#	go.sum
@ti-chi-bot ti-chi-bot Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 3, 2026
Comment thread cmd/tidb-server/main.go Outdated
Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ti-chi-bot
ti-chi-bot Bot merged commit 0c62aa5 into pingcap:master Jun 3, 2026
36 checks passed
@ekexium

ekexium commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

/cherry-pick release-8.5

@ti-chi-bot

Copy link
Copy Markdown
Member

@ekexium: new pull request created to branch release-8.5: #68960.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-8.5

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 ti-community-infra/tichi repository.

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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make TiKV identify TiDB requests and strengthen TS checks for non-TiDB requests

6 participants