tidb icon indicating copy to clipboard operation
tidb copied to clipboard

ddl: support to set and alter the `AFFINITY` for table

Open lcwangchao opened this issue 2 weeks ago • 4 comments

What problem does this PR solve?

Issue Number: ref #64938

What changed and how does it work?

  • Support a new optionAFFINITY for table, for example:
CREATE TABLE t(a int) AFFINITY 'table';

The above DDL indicates creating a table with a table-level affinity which will cluster all the table's data into one region.

  • Add a new column TIDB_AFFINITY to table information_schema.TABLES and information_schema.PARTITONS

  • forbid add / drop / exchange / reorg partition on affinity table

Check List

Tests

  • [ ] Unit test
  • [x] 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.

support to set and alter the `AFFINITY` for table

lcwangchao avatar Dec 11 '25 07:12 lcwangchao

Codecov Report

:x: Patch coverage is 72.77228% with 55 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 71.4647%. Comparing base (5271f75) to head (3ab80f3). :warning: Report is 13 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #64988        +/-   ##
================================================
+ Coverage   70.9053%   71.4647%   +0.5594%     
================================================
  Files          1888       1889         +1     
  Lines        515654     519719      +4065     
================================================
+ Hits         365626     371416      +5790     
+ Misses       125622     123899      -1723     
+ Partials      24406      24404         -2     
Flag Coverage Δ
integration 48.2535% <70.4301%> (+0.0970%) :arrow_up:
unit 66.0477% <22.7722%> (+0.4073%) :arrow_up:

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

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 60.9232% <ø> (+1.5279%) :arrow_up:
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Dec 11 '25 07:12 codecov[bot]

/retest

lcwangchao avatar Dec 11 '25 14:12 lcwangchao

/retest

lcwangchao avatar Dec 12 '25 00:12 lcwangchao

/retest

lcwangchao avatar Dec 12 '25 02:12 lcwangchao

/retest

lcwangchao avatar Dec 12 '25 02:12 lcwangchao

/retest

lcwangchao avatar Dec 12 '25 04:12 lcwangchao

/retest

lcwangchao avatar Dec 12 '25 06:12 lcwangchao

/retest

lcwangchao avatar Dec 12 '25 06:12 lcwangchao

/retest

lcwangchao avatar Dec 12 '25 07:12 lcwangchao

A small question, do we need to ignore PRE_SPLIT_REGIONS when AFFINITY is enabled. If I understand correctly, PRE_SPLIT_REGIONS will split the region, and those regions will be merged by PD later again due to we need to maintain affinity.

good catch. But I think we do not need to handle it yet because it does not introduce any correctness problem.

lcwangchao avatar Dec 12 '25 09:12 lcwangchao

good catch. But I think we do not need to handle it yet because it does not introduce any correctness problem.

LGTM

joechenrh avatar Dec 12 '25 10:12 joechenrh

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

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[bot] avatar Dec 12 '25 10:12 ti-chi-bot[bot]

/retest

joechenrh avatar Dec 12 '25 13:12 joechenrh

/retest

lhy1024 avatar Dec 12 '25 13:12 lhy1024

/retest

lcwangchao avatar Dec 13 '25 00:12 lcwangchao

/retest

lcwangchao avatar Dec 13 '25 03:12 lcwangchao

[LGTM Timeline notifier]

Timeline:

  • 2025-12-12 07:20:02.164376117 +0000 UTC m=+1198346.978153689: :ballot_box_with_check: agreed by cfzjywxk.
  • 2025-12-14 06:10:01.112340355 +0000 UTC m=+1366945.926117946: :ballot_box_with_check: agreed by fzzf678.

ti-chi-bot[bot] avatar Dec 14 '25 06:12 ti-chi-bot[bot]

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, cfzjywxk, fzzf678, lhy1024, yudongusa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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[bot] avatar Dec 15 '25 02:12 ti-chi-bot[bot]