Skip to content

[feat(router service)]:support new option for WithAllowRouterServiceHandle for access router service#1797

Merged
ti-chi-bot[bot] merged 8 commits intotikv:masterfrom
bufferflies:mcs/router
Feb 3, 2026
Merged

[feat(router service)]:support new option for WithAllowRouterServiceHandle for access router service#1797
ti-chi-bot[bot] merged 8 commits intotikv:masterfrom
bufferflies:mcs/router

Conversation

@bufferflies
Copy link
Copy Markdown
Contributor

@bufferflies bufferflies commented Nov 14, 2025

tidb dep ref : https://github.com/pingcap/tidb/compare/master...bufferflies:tidb:feat/support_router?expand=1

Summary by CodeRabbit

  • Chores

    • Updated numerous Go module dependency versions across examples, tests, and root modules (gRPC/protobuf and related indirect deps); added local replace directives.
  • Improvements

    • Broadened region and store lookup to allow router-service handling during retrievals and scans.
    • Store resolution now accepts and forwards additional retrieval options on initial fetches and during cache refreshes.
  • Tests

    • Mocks and integration tests updated to support the new optional retrieval options.

✏️ Tip: You can customize this high-level summary in your review settings.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 14, 2025
@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 11, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

Added router-service PD options to region and store lookups; extended store fetch API to accept variadic GetStore options (one-time router option on initial resolve); updated PD interceptor, mocks, and tests to forward GetStore options; bumped PD client and multiple indirect Go module versions across examples and integration tests.

Changes

Cohort / File(s) Summary
Dependency Version Updates
go.mod, integration_tests/go.mod, examples/gcworker/go.mod, examples/rawkv/go.mod, examples/txnkv/*.go.mod
Bumped github.com/tikv/pd/client pseudo-version and multiple indirect deps (golang.org/x/*, google.golang.org/grpc, google.golang.org/protobuf, genproto). integration_tests/go.mod also updates/adds several indirects and uses replace directives.
Region cache: PD call options
internal/locate/region_cache.go
Region load/scan and batch-scan calls now include opt.WithAllowRouterServiceHandle() alongside existing follower options when retrieving regions.
Store cache: API & one-time option
internal/locate/store_cache.go
storeRegistry.fetchStore and storeCacheImpl.fetchStore now accept opts ...opt.GetStoreOption; initial resolve applies a one-time opt.WithAllowRouterServiceHandleStoreRequest(); updater uses router-store option with opt.WithExcludeTombstone().
PD interceptor & mocks: forward options
util/pd_interceptor.go, internal/mockstore/mocktikv/pd.go, integration_tests/split_test.go
GetStore signature changed to accept opts ...opt.GetStoreOption; interceptor, mock, and test implementations forward opts... to the underlying PD client.

Sequence Diagram(s)

sequenceDiagram
  participant Cache as Cache (region/store)
  participant PD as PD Client
  participant Router as Router Service
  participant Store as Store Meta

  Cache->>PD: GetRegion/GetStore(ctx, id, opts: AllowFollowerHandle, AllowRouterServiceHandle)
  PD->>Router: route request (router-service option present)
  Router-->>PD: routed response
  PD->>Store: GetStore(ctx, storeID, opts...)
  Store-->>PD: store metadata
  PD-->>Cache: return region/store metadata
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • cfzjywxk
  • ekexium

Poem

🐇 I nudged some modules, hopped the PD trail,

A one-time wink then routers set sail.
Caches learned new steps, options now pass through,
Mocks and tests echo the routed view.
✨ Hopping on — builds smoother and new.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for a new WithAllowRouterServiceHandle option for router service access, which is reflected across multiple files including region_cache.go and store_cache.go.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@bufferflies bufferflies marked this pull request as ready for review January 21, 2026 07:53
@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 Jan 21, 2026
Signed-off-by: bufferflies <1045931706@qq.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@internal/locate/store_cache.go`:
- Around line 59-61: Update the method signature of storeCacheImpl.fetchStore to
accept the new variadic options parameter so it matches storeRegistry: change
fetchStore(ctx context.Context, id uint64) to fetchStore(ctx context.Context, id
uint64, opts ...opt.GetStoreOption); within the method forward those opts when
calling the underlying registry/fetch (and update any internal calls to pass
through opts), and update any places that call storeCacheImpl.fetchStore to
supply or forward the options as needed so the implementation satisfies the
storeRegistry interface.
♻️ Duplicate comments (5)
examples/txnkv/async_commit/go.mod (1)

34-34: Same pd/client bump verification applies here.
Please see the verification request in the root go.mod review comment.

examples/gcworker/go.mod (1)

34-34: Same pd/client bump verification applies here.
Please see the verification request in the root go.mod review comment.

examples/txnkv/pessimistic_txn/go.mod (1)

34-34: Same pd/client bump verification applies here.
Please see the verification request in the root go.mod review comment.

examples/rawkv/go.mod (1)

34-34: Same pd/client bump verification applies here.
Please see the verification request in the root go.mod review comment.

examples/txnkv/delete_range/go.mod (1)

34-34: Same pd/client bump verification applies here.
Please see the verification request in the root go.mod review comment.

Comment thread internal/locate/store_cache.go
Signed-off-by: bufferflies <1045931706@qq.com>
Signed-off-by: bufferflies <1045931706@qq.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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 21, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@integration_tests/go.mod`:
- Around line 182-183: Update the PR and repository notes to document the fork
usage: state whether the TiDB changes in the go.mod replace directives
(github.com/pingcap/tidb => github.com/bufferflies/tidb and
github.com/pingcap/tidb/pkg/parser => github.com/bufferflies/tidb/pkg/parser)
are intended to be upstreamed to pingcap/tidb, provide a concrete
timeline/milestones for replacing the fork with canonical versions before
merging to master, and enumerate the exact patches/commits or feature diffs from
the fork required to support the router service so reviewers and downstreams can
reproduce and evaluate the changes.
🧹 Nitpick comments (1)
integration_tests/go.mod (1)

37-38: Check for security advisories in updated indirect dependencies.

Recent CVEs have been published for golang.org/x/crypto and golang.org/x/net. While the versions in this update (v0.47.0 and v0.49.0 respectively) are patched versions, it's good practice to review the security changelog:

  • golang.org/x/crypto — Several SSH-related DoS CVEs fixed in v0.45.0 and earlier
  • golang.org/x/net — NO_PROXY and HTML parsing CVEs addressed in recent patches
  • Other dependencies (gopkg.in/ini.v1, Alibaba Cloud packages) have no known public advisories at their specified versions

Comment thread integration_tests/go.mod Outdated
Comment on lines +182 to +183
github.com/pingcap/tidb => github.com/bufferflies/tidb v0.0.0-20260121115107-e127d738bb02
github.com/pingcap/tidb/pkg/parser => github.com/bufferflies/tidb/pkg/parser v0.0.0-20260121115107-e127d738bb02
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if integration_tests/go.mod exists and read the relevant lines

if [ -f "integration_tests/go.mod" ]; then
  echo "=== File exists. Reading lines 180-185 for context ==="
  sed -n '180,185p' integration_tests/go.mod | cat -n
  echo ""
  echo "=== Total lines in file ==="
  wc -l integration_tests/go.mod
else
  echo "File not found at integration_tests/go.mod"
  # Try to locate it
  find . -name "go.mod" -type f 2>/dev/null | head -10
fi

Repository: tikv/client-go

Length of output: 561


🏁 Script executed:

#!/bin/bash
# Search for recent commits or messages related to bufferflies or this fork
echo "=== Searching git log for 'bufferflies' or 'tidb' fork references ==="
git log --oneline --all --grep="bufferflies\|fork" 2>/dev/null | head -20

echo ""
echo "=== Searching for any documentation about this fork ==="
find . -type f \( -name "*.md" -o -name "*.txt" \) -exec grep -l "bufferflies\|fork.*tidb" {} \; 2>/dev/null | head -10

Repository: tikv/client-go

Length of output: 663


🏁 Script executed:

#!/bin/bash
# Check recent changes to go.mod file
echo "=== Recent commits touching go.mod files ==="
git log --oneline --all -- "**/go.mod" 2>/dev/null | head -15

echo ""
echo "=== Check if there's a go.mod in root or other locations ==="
find . -maxdepth 3 -name "go.mod" -type f 2>/dev/null

Repository: tikv/client-go

Length of output: 1315


Fork replacement requires clarification on upstreaming and timeline.

The replace directives point to a fork (bufferflies/tidb) instead of the canonical pingcap/tidb repository. While this may be acceptable for development/testing, this setup:

  1. Prevents reproducible builds in downstream consumers
  2. Requires clarity on what changes in the fork are necessary
  3. Needs a defined timeline and plan for migrating back to canonical versions before merging to master

Please clarify:

  • Are these TiDB changes planned to be upstreamed to pingcap/tidb?
  • What is the timeline for replacing this fork with canonical versions?
  • What specific changes in the fork are required for the router service support?
🤖 Prompt for AI Agents
In `@integration_tests/go.mod` around lines 182 - 183, Update the PR and
repository notes to document the fork usage: state whether the TiDB changes in
the go.mod replace directives (github.com/pingcap/tidb =>
github.com/bufferflies/tidb and github.com/pingcap/tidb/pkg/parser =>
github.com/bufferflies/tidb/pkg/parser) are intended to be upstreamed to
pingcap/tidb, provide a concrete timeline/milestones for replacing the fork with
canonical versions before merging to master, and enumerate the exact
patches/commits or feature diffs from the fork required to support the router
service so reviewers and downstreams can reproduce and evaluate the changes.

Signed-off-by: bufferflies <1045931706@qq.com>
Signed-off-by: bufferflies <1045931706@qq.com>
Signed-off-by: bufferflies <1045931706@qq.com>
@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jan 22, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 22, 2026

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

@bufferflies bufferflies requested a review from rleungx January 22, 2026 08:09
Signed-off-by: bufferflies <1045931706@qq.com>
@ti-chi-bot ti-chi-bot Bot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 22, 2026
@ti-chi-bot ti-chi-bot Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 22, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@examples/rawkv/go.mod`:
- Line 34: Confirm and validate the updated Go module dependencies by checking
that github.com/tikv/pd/client v0.0.0-20260122075414-848dd85011e9,
google.golang.org/grpc v1.75.1, and google.golang.org/protobuf v1.36.6 are
intentional and secure: run go mod tidy to resolve and clean modules, run a
vulnerability scan (e.g., go list -json ./... | nancy sleuth or `govulncheck`)
against these modules, and if any advisories appear pin or roll back the
offending module(s) or update to a patched release; ensure the final
go.mod/go.sum reflect the chosen, verified versions for
github.com/tikv/pd/client, google.golang.org/grpc, and
google.golang.org/protobuf.

In `@examples/txnkv/async_commit/go.mod`:
- Around line 34-49: Update the vulnerable dependency golang.org/x/net to
v0.45.0 or later in the module list (replace the existing golang.org/x/net
v0.41.0 entry), and verify the availability of the pseudo-version for
github.com/tikv/pd/client v0.0.0-20260122075414 by querying the Go module proxy
or listing available versions (use go list -m -versions or fetch the proxy
metadata) before committing; adjust the tikv/pd/client version to a resolvable
tag or commit if the pseudo-version is not present.

In `@examples/txnkv/delete_range/go.mod`:
- Around line 34-49: The google.golang.org/genproto pseudo-version listed
(v0.0.0-20250707201910-8d1bb00bc6a7) requires Go toolchain >= 1.22.11 and
changes submodule layout; verify your Go version and either upgrade the project
toolchain or pin genproto to a compatible release (or revert to the prior
genproto version) in go.mod, then run go mod tidy and build/test the code to
confirm imports resolve; also consider updating google.golang.org/grpc and
google.golang.org/protobuf to their newer patch releases (e.g., grpc v1.76.0,
protobuf v1.36.11) if you want the latest patches.
♻️ Duplicate comments (1)
integration_tests/go.mod (1)

183-185: Fork dependency issue previously flagged.

The replace directives pointing to github.com/bufferflies/tidb fork have already been identified in previous review comments. Please address the concerns raised about upstreaming timeline and migration plan.

Comment thread examples/rawkv/go.mod
Comment thread examples/txnkv/async_commit/go.mod
Comment thread examples/txnkv/delete_range/go.mod
Signed-off-by: bufferflies <1045931706@qq.com>
Comment thread internal/locate/region_cache.go
@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 30, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 30, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-22 02:33:21.332870758 +0000 UTC m=+634028.946827614: ☑️ agreed by lcwangchao.
  • 2026-01-30 10:08:33.999368287 +0000 UTC m=+1352541.613325133: ☑️ agreed by rleungx.

@bufferflies
Copy link
Copy Markdown
Contributor Author

/ping @you06

Copy link
Copy Markdown
Contributor

@you06 you06 left a comment

Choose a reason for hiding this comment

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

rest LGTM

Comment thread internal/locate/region_cache.go
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Feb 3, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lcwangchao, okJiang, rleungx, you06

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 Feb 3, 2026
@ti-chi-bot ti-chi-bot Bot merged commit 362e1a2 into tikv:master Feb 3, 2026
18 of 19 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.

5 participants