Skip to content

ddl,executor: fix usages of getting regions from pd client#63371

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
tangenta:next-gen-fix-get-region
Sep 4, 2025
Merged

ddl,executor: fix usages of getting regions from pd client#63371
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
tangenta:next-gen-fix-get-region

Conversation

@tangenta

@tangenta tangenta commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:

The old impl doesn't work in next-gen because the keys are not encoded by the keyspace.

What changed and how does it work?

  • Use store.GetCodec() to encode region ranges before sending get-region requests.
  • Add a test for information_schema.tikv_region_status.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    Sysbench 20,000,000 rows (tableSizeInBytes=4.092GiB):
[2025/09/04 14:44:00.614 +08:00] [INFO] [reorg_util.go:134] ["initialize reorg meta"] [keyspaceName=keyspace1] [category=ddl] [jobSchema=test] [jobTable=sbtest1] [jobType="add index"] [enableDistTask=true] [enableFastReorg=true] [targetScope=dxf_service] [maxNodeCount=1] [tableSizeInBytes=4.092GiB] [concurrency=1] [batchSize=256]

Before this PR:

mysql> select * from information_schema.tikv_region_status where table_id = 7;
+-----------+--------------------+--------------------+----------+---------+------------+----------+----------+------------+--------------+--------------+----------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
| REGION_ID | START_KEY          | END_KEY            | TABLE_ID | DB_NAME | TABLE_NAME | IS_INDEX | INDEX_ID | INDEX_NAME | IS_PARTITION | PARTITION_ID | PARTITION_NAME | EPOCH_CONF_VER | EPOCH_VERSION | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE | APPROXIMATE_KEYS | REPLICATIONSTATUS_STATE | REPLICATIONSTATUS_STATEID |
+-----------+--------------------+--------------------+----------+---------+------------+----------+----------+------------+--------------+--------------+----------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
|        14 | 72FFFFFF00000000FB | 7800000100000000FB |        7 | test    | sbtest1    |        1 |        1 | k_1        |            0 |         NULL | NULL           |              1 |            11 |             0 |          0 |                1 |                0 | NULL                    |                      NULL |
|        14 | 72FFFFFF00000000FB | 7800000100000000FB |        7 | test    | sbtest1    |        0 |     NULL | NULL       |            0 |         NULL | NULL           |              1 |            11 |             0 |          0 |                1 |                0 | NULL                    |                      NULL |
+-----------+--------------------+--------------------+----------+---------+------------+----------+----------+------------+--------------+--------------+----------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
2 rows in set (1 min 20.46 sec)

mysql> show table sbtest1 regions;
+-----------+------------------------------------------------+------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
| REGION_ID | START_KEY                                      | END_KEY                                        | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS | SCHEDULING_CONSTRAINTS | SCHEDULING_STATE |
+-----------+------------------------------------------------+------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
|       270 | t_7_i_1_038000000001089dc20380000000000c530300 | t_7_r_4716102                                  |       271 |               1 | 271   |          0 |             0 |          0 |                 1031 |          4741227 |                        |                  |
|       272 | t_7_r_4716102                                  | t_7_r_9358899                                  |       273 |               1 | 273   |          0 |             0 |          0 |                 1029 |          4670598 |                        |                  |
|       274 | t_7_r_9358899                                  | t_7_r_14381182                                 |       275 |               1 | 275   |          0 |             0 |          0 |                 1040 |          5041457 |                        |                  |
|       146 | t_7_r_14381182                                 | t_281474976710596_                             |       147 |               1 | 147   |          0 |             0 |          0 |                 1177 |          5735440 |                        |                  |
|       276 | t_7_                                           | t_7_i_1_0380000000002426cb03800000000054a65e   |       277 |               1 | 277   |          0 |             0 |          0 |                    1 |                0 |                        |                  |
|       278 | t_7_i_1_0380000000002426cb03800000000054a65e   | t_7_i_1_03800000000098f7150380000000002ccea1   |       279 |               1 | 279   |          0 |             0 |          0 |                   72 |          9998595 |                        |                  |
|       280 | t_7_i_1_03800000000098f7150380000000002ccea1   | t_7_i_1_038000000001089dc20380000000000c530300 |       281 |               1 | 281   |          0 |             0 |          0 |                   72 |         10001405 |                        |                  |
+-----------+------------------------------------------------+------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
7 rows in set (0.01 sec)

After this PR:

mysql> show table sbtest1 regions;
+-----------+-------------------------------------------------+-------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
| REGION_ID | START_KEY                                       | END_KEY                                         | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS | SCHEDULING_CONSTRAINTS | SCHEDULING_STATE |
+-----------+-------------------------------------------------+-------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
|       274 | t_15_i_1_038000000001089dc20380000000000c475b00 | t_15_r_5337962                                  |       275 |               1 | 275   |          0 |             0 |          0 |                 1027 |          5366615 |                        |                  |
|       276 | t_15_r_5337962                                  | t_15_r_10418020                                 |       277 |               1 | 277   |          0 |             0 |          0 |                 1034 |          5097457 |                        |                  |
|       278 | t_15_r_10418020                                 | t_15_r_14976190                                 |       279 |               1 | 279   |          0 |             0 |          0 |                 1010 |          4609699 |                        |                  |
|       146 | t_15_r_14976190                                 | t_281474976710596_                              |       147 |               1 | 147   |          0 |             0 |          0 |                 1127 |          5124631 |                        |                  |
|       280 | t_15_                                           | t_15_i_1_0380000000002426cb0380000000005494a1   |       281 |               1 | 281   |          0 |             0 |          0 |                    1 |                0 |                        |                  |
|       282 | t_15_i_1_0380000000002426cb0380000000005494a1   | t_15_i_1_03800000000098f7150380000000002cc988   |       283 |               1 | 283   |          0 |             0 |          0 |                   72 |          9998595 |                        |                  |
|       284 | t_15_i_1_03800000000098f7150380000000002cc988   | t_15_i_1_038000000001089dc20380000000000c475b00 |       285 |               1 | 285   |          0 |             0 |          0 |                   72 |         10001405 |                        |                  |
+-----------+-------------------------------------------------+-------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
7 rows in set (0.01 sec)

mysql> select * from information_schema.tikv_region_status where table_id = 15;
+-----------+--------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+----------+---------+------------+----------+----------+------------+--------------+--------------+----------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
| REGION_ID | START_KEY                                                                                                    | END_KEY                                                | TABLE_ID | DB_NAME | TABLE_NAME | IS_INDEX | INDEX_ID | INDEX_NAME | IS_PARTITION | PARTITION_ID | PARTITION_NAME | EPOCH_CONF_VER | EPOCH_VERSION | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE | APPROXIMATE_KEYS | REPLICATIONSTATUS_STATE | REPLICATIONSTATUS_STATEID |
+-----------+--------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+----------+---------+------------+----------+----------+------------+--------------+--------------+----------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
|       274 | 7800000174800000FF000000000F5F6980FF0000000000000103FF8000000001089DC2FF0380000000000C47FF5B00000000000000F9 | 7800000174800000FF000000000F5F7280FF0000000051736A00FE |     NULL | NULL    | NULL       |        0 |     NULL | NULL       |            0 |         NULL | NULL           |              1 |            72 |             0 |          0 |             1027 |          5366615 | NULL                    |                      NULL |
|       276 | 7800000174800000FF000000000F5F7280FF0000000051736A00FE                                                       | 7800000174800000FF000000000F5F7280FF000000009EF76400FE |     NULL | NULL    | NULL       |        0 |     NULL | NULL       |            0 |         NULL | NULL           |              1 |            70 |             0 |          0 |             1034 |          5097457 | NULL                    |                      NULL |
|       278 | 7800000174800000FF000000000F5F7280FF000000009EF76400FE                                                       | 7800000174800000FF000000000F5F7280FF00000000E484BE00FE |     NULL | NULL    | NULL       |        0 |     NULL | NULL       |            0 |         NULL | NULL           |              1 |            71 |             0 |          0 |             1010 |          4609699 | NULL                    |                      NULL |
|       146 | 7800000174800000FF000000000F5F7280FF00000000E484BE00FE                                                       | 78000001748000FFFFFFFFFFFFC4000000FC                   |     NULL | NULL    | NULL       |        0 |     NULL | NULL       |            0 |         NULL | NULL           |              1 |            71 |             0 |          0 |             1127 |          5124631 | NULL                    |                      NULL |
+-----------+--------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+----------+---------+------------+----------+----------+------------+--------------+--------------+----------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
4 rows in set (0.01 sec)
  • 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

Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 4, 2025
@tiprow

tiprow Bot commented Sep 4, 2025

Copy link
Copy Markdown

Hi @tangenta. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@D3Hunter

D3Hunter commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

/cherry-pick release-nextgen-20250815

@ti-chi-bot ti-chi-bot Bot added the approved label Sep 4, 2025
@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: once the present PR merges, I will cherry-pick it on top of release-nextgen-20250815 in the new PR and assign it to you.

Details

In response to this:

/cherry-pick release-nextgen-20250815

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.

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 4, 2025
@codecov

codecov Bot commented Sep 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.9833%. Comparing base (7a817f4) to head (59e4f25).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #63371        +/-   ##
================================================
+ Coverage   72.7817%   74.9833%   +2.2016%     
================================================
  Files          1832       1878        +46     
  Lines        495807     507079     +11272     
================================================
+ Hits         360857     380225     +19368     
+ Misses       113007     103498      -9509     
- Partials      21943      23356      +1413     
Flag Coverage Δ
integration 48.6249% <0.0000%> (?)
unit 72.3621% <0.0000%> (+0.1039%) ⬆️

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

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 63.3116% <ø> (+16.7898%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 4, 2025
@ti-chi-bot

ti-chi-bot Bot commented Sep 4, 2025

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2025-09-04 07:52:09.732195116 +0000 UTC m=+79873.715292564: ☑️ agreed by D3Hunter.
  • 2025-09-04 08:08:35.350576027 +0000 UTC m=+80859.333673476: ☑️ agreed by JmPotato.

@GMHDBJD GMHDBJD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot

ti-chi-bot Bot commented Sep 4, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, GMHDBJD, JmPotato

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

@tangenta

tangenta commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Sep 4, 2025

Copy link
Copy Markdown

@tangenta: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@D3Hunter

D3Hunter commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

/retest

@tiprow

tiprow Bot commented Sep 4, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@tangenta

tangenta commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Sep 4, 2025

Copy link
Copy Markdown

@tangenta: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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 ti-chi-bot Bot merged commit b82dd2c into pingcap:master Sep 4, 2025
31 checks passed
@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: new pull request created to branch release-nextgen-20250815: #63379.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-nextgen-20250815

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.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 4, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants