Skip to content

table-affinity: clarify scheduling microservice version support - #24206

Open
lhy1024 wants to merge 5 commits into
pingcap:masterfrom
lhy1024:fix/affinity-microservices-version
Open

lhy1024 wants to merge 5 commits into
pingcap:masterfrom
lhy1024:fix/affinity-microservices-version

Conversation

@lhy1024

@lhy1024 lhy1024 commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

What is changed, added, or deleted? (Required)

Replace the blanket PD microservices limitation in table-affinity.md with an explicit distinction between deployment modes: table-level data affinity is available starting from v8.5.5 when PD is not deployed in PD Microservices Mode, and in PD Microservices Mode when scheduling is handled by the scheduling microservice starting from v8.5.7. The scheduling microservice affinity metadata synchronization was added by tikv/pd#10042 and backported in tikv/pd#10232; the split restriction was backported by tikv/pd#10714.

Use the verified v8.5.7 version boundary in master and release-8.5.

Validation: ./scripts/markdownlint table-affinity.md; verified the affinity metadata and split restriction backport boundaries in the PD v8.5 tags.

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • Documentation
    • Clarified that table-level data affinity is available in PD classic mode starting with v8.5.5, and in PD Microservices Mode starting with v8.5.6 when scheduling is handled by the scheduling microservice.

Signed-off-by: lhy1024 <19542290+lhy1024@users.noreply.github.com>
@lhy1024 lhy1024 added type/bugfix This PR fixes a bug. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. labels Oct 8, 2026
@ti-chi-bot

ti-chi-bot Bot commented Oct 8, 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 csuzhangxc 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 missing-translation-status This PR does not have translation status info. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 8, 2026
@lhy1024 lhy1024 added the translation/welcome Waits for a contributor to translate this PR and create a PR to the pingcap/docs-cn repository. label Oct 8, 2026
@ti-chi-bot ti-chi-bot Bot removed the missing-translation-status This PR does not have translation status info. label Oct 8, 2026
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The documentation states that table-level data affinity is available from v8.5.5 outside PD Microservices Mode, and from v8.5.7 in that mode when the scheduling microservice handles scheduling. It removes the limitation that affinity does not take effect in PD Microservices Mode.

Changes

Affinity scheduling documentation

Layer / File(s) Summary
Version-specific availability
table-affinity.md
The documentation gives the availability versions for each deployment mode and removes the limitation for PD Microservices Mode.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other

Suggested reviewers: jmpotato, rleungx

Merge Risk: 🔵 Low · up to e70d5

The updated page extends its affinity guidance to PD Microservices Mode, but its splitting note does not describe the MCS size and key-count triggers. Operators may misjudge when automatic Region splitting occurs; this is a bounded documentation risk.

Architecture Summary

Architecture risk: 🔵 Low · up to e70d5

The change affects 1 system.

Changed systems: table-affinity.md

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — table-affinity.md (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in table-affinity.md: Documents availability from v8.5.5 when PD is not deployed in PD Microservices Mode, and from v8.5.7 in PD Microservices Mode when scheduling is handled by the scheduling microservice.
  • observed — Modified behavior in table-affinity.md: Removes the limitation that affinity does not take effect in PD Microservices Mode; the remaining limitations heading and introductory text are unchanged.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
Title check ✅ Passed The title clearly identifies the table-affinity change and the scheduling microservice version support it clarifies.
Description check ✅ Passed The description explains the change, identifies the affected versions, provides related links, and reports validation. It covers the required template sections.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: lhy1024 <19542290+lhy1024@users.noreply.github.com>
@lhy1024 lhy1024 added the requires-version-specific-changes After cherry-picked, the cherry-picked PR requires further changes. label Oct 8, 2026
Signed-off-by: lhy1024 <19542290+lhy1024@users.noreply.github.com>
@lhy1024 lhy1024 removed the requires-version-specific-changes After cherry-picked, the cherry-picked PR requires further changes. label Oct 8, 2026
Signed-off-by: lhy1024 <19542290+lhy1024@users.noreply.github.com>
@ti-chi-bot

ti-chi-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

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

Comment thread table-affinity.md Outdated

When you enable PD affinity scheduling and set the `AFFINITY` option of a table to `table` or `partition`, PD groups Regions belonging to the same table or partition into the same affinity group. During scheduling, PD prioritizes placing the Leader and Voter replicas of these Regions on the same subset of a few TiKV nodes. This reduces network latency caused by cross-node access during queries, thereby improving query performance.

Table-level data affinity is available in PD's classic deployment mode starting from v8.5.5. Starting from v8.5.6, it is also available when scheduling is handled by the scheduling microservice in [PD Microservices Mode](/pd-microservices.md).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

v8.5.6 seems too early for PD Microservices Mode. In v8.5.6, the scheduling microservice syncs affinity groups (tikv/pd#10232), but its AskBatchSplit handler does not check affinity, and PD does not forward the split reason. As a result, Regions in an affinity group are still split automatically, which contradicts the "Automatic splitting of Regions" behavior described later on this page. The split restriction reached release-8.5 via tikv/pd#10714 (backport of tikv/pd#10652), which is first included in v8.5.7.

Also, "PD's classic deployment mode" is not a term used elsewhere in the docs, so it might be clearer to describe it relative to PD Microservices Mode.

Suggested change
Table-level data affinity is available in PD's classic deployment mode starting from v8.5.5. Starting from v8.5.6, it is also available when scheduling is handled by the scheduling microservice in [PD Microservices Mode](/pd-microservices.md).
Table-level data affinity is available starting from v8.5.5 when PD is not deployed in [PD Microservices Mode](/pd-microservices.md). Starting from v8.5.7, it is also available in PD Microservices Mode when scheduling is handled by the scheduling microservice.

Signed-off-by: lhy1024 <19542290+lhy1024@users.noreply.github.com>

@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


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: pingcap/docs/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3cde11bd-35d2-4a2a-bbc6-113e78e405dd
📥 Commits

Reviewing files that changed from the base of the PR and between 1d64d5f and e70d552.

📒 Files selected for processing (1)
  • table-affinity.md

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

Comment thread table-affinity.md

When you enable PD affinity scheduling and set the `AFFINITY` option of a table to `table` or `partition`, PD groups Regions belonging to the same table or partition into the same affinity group. During scheduling, PD prioritizes placing the Leader and Voter replicas of these Regions on the same subset of a few TiKV nodes. This reduces network latency caused by cross-node access during queries, thereby improving query performance.

Table-level data affinity is available starting from v8.5.5 when PD is not deployed in [PD Microservices Mode](/pd-microservices.md). Starting from v8.5.7, it is also available in PD Microservices Mode when scheduling is handled by the scheduling microservice.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -u
printf '%s\n' '--- changed file context ---'
nl -ba table-affinity.md | sed -n '10,30p'
printf '%s\n' '--- PR diff for the file ---'
git diff --no-ext-diff --unified=12 6ba85765e2f9e8d080a7f1789a3b46641a09d960 e70d552cc8e7dba3ee7c458c6080e2bc4a7660ea -- table-affinity.md
printf '%s\n' '--- local predicate/source references ---'
rg -n -F --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' -- 'affinityRegionSizeBufferMB' . || test "$?" -eq 1
rg -n -F --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' -- 'ApproximateKeys' . || test "$?" -eq 1
printf '%s\n' '--- splitting wording references ---'
rg -n -F -- 'four times' . || test "$?" -eq 1

Repository: pingcap/docs

Length of output: 7915


🌐 Web query:

site:github.com/tikv/pd v8.5.7 pkg/schedule/affinity/split.go grpc_service.go MCS scheduling affinity split

💡 Result:

In **PD v8.5.7**, affinity split handling is split across these files:

- [`pkg/schedule/affinity/split.go`](https://github.com/tikv/pd/blob/v8.5.7/pkg/schedule/affinity/split.go): `Manager.AllowSplit` allows splitting for nil regions, admin splits, or when affinity scheduling is disabled. For affinity regions where regular scheduling is disallowed, it blocks automatic splits below a size/key threshold; larger regions may still split. ([raw.githubusercontent.com](https://raw.githubusercontent.com/tikv/pd/v8.5.7/pkg/schedule/affinity/split.go))
- [`pkg/mcs/scheduling/server/grpc_service.go`](https://github.com/tikv/pd/blob/v8.5.7/pkg/mcs/scheduling/server/grpc_service.go): `AskBatchSplit` calls `AllowSplit`. If denied, it disables auto-splitting for the region and returns `"cannot split affinity region"`; otherwise it allocates the new region and peer IDs. ([raw.githubusercontent.com](https://raw.githubusercontent.com/tikv/pd/v8.5.7/pkg/mcs/scheduling/server/grpc_service.go))
- [`server/grpc_service.go`](https://github.com/tikv/pd/blob/v8.5.7/server/grpc_service.go) is the PD server’s separate gRPC implementation. The MCS scheduling split path is in `pkg/mcs/scheduling/server/grpc_service.go`, not this file. ([raw.githubusercontent.com](https://raw.githubusercontent.com/tikv/pd/v8.5.7/server/grpc_service.go))

These links and findings are for the **v8.5.7** tag.

Citations:

- 1: https://raw.githubusercontent.com/tikv/pd/v8.5.7/pkg/schedule/affinity/split.go
- 2: https://raw.githubusercontent.com/tikv/pd/v8.5.7/pkg/mcs/scheduling/server/grpc_service.go
- 3: https://raw.githubusercontent.com/tikv/pd/v8.5.7/server/grpc_service.go

Document both automatic-splitting triggers for MCS.

The new availability statement makes the automatic-splitting note apply to MCS. In v8.5.7, AskBatchSplit calls AllowSplit, which permits splitting when approximate size reaches (configured merge size + 10 MiB) × 4 or approximate key count reaches its threshold. The current “only when ... exceeds four times” wording can cause operators to miss key-count-triggered splits and use an incorrect size threshold.

Suggested fix
-- **Automatic splitting of Regions**: when a Region belongs to an affinity group and affinity is in effect, automatic splitting of that Region is disabled by default to avoid the creation of too many Regions that could weaken the affinity effect. Automatic splitting is triggered only when the Region size exceeds four times the value of [`schedule.max-affinity-merge-region-size`](/pd-configuration-file.md#max-affinity-merge-region-size-new-in-v855-and-v900). Note that splits triggered by components other than TiKV or PD (such as manual splits triggered by [`SPLIT TABLE`](/sql-statements/sql-statement-split-region.md)) are not subject to this restriction.
+- **Automatic splitting of Regions**: when a Region belongs to an affinity group and affinity is in effect, automatic splitting of that Region is disabled by default to avoid the creation of too many Regions that could weaken the affinity effect. Automatic splitting is triggered when the Region's approximate size reaches four times the value of [`schedule.max-affinity-merge-region-size`](/pd-configuration-file.md#max-affinity-merge-region-size-new-in-v855-and-v900) plus the 10 MiB buffer, or when its approximate key count reaches the configured threshold. Note that splits triggered by components other than TiKV or PD (such as manual splits triggered by [`SPLIT TABLE`](/sql-statements/sql-statement-split-region.md)) are not subject to this restriction.

@lhy1024

lhy1024 commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

@JmPotato PTAL

@lhy1024

lhy1024 commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

@qiancai Could you help move this PR forward to merge? The content is final: following JmPotato's review, the PD microservices support now starts from v8.5.7, which includes tikv/pd#10714. It also needs to be cherry-picked to release-8.5. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. translation/welcome Waits for a contributor to translate this PR and create a PR to the pingcap/docs-cn repository. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants