Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: fix issue pre_split_regions table option doesn't work in the partition table. #18144

Merged
merged 4 commits into from
Jun 29, 2020

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Jun 19, 2020

Signed-off-by: crazycs520 crazycs520@gmail.com

What problem does this PR solve?

Close #14478

When create partition table, the pre_split_regions table option doesn't work.

create table t (a int, b int) shard_row_id_bits = 2 pre_split_regions=2 partition by hash(a) partitions 3;

After create table, before this PR, TiDB only split 1 regino for the separate partition:

>show table t regions;
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY | END_KEY | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| 44        | t_46_     | t_47_   | 45        | 1               | 45    | 0          | 0             | 0          | 0                    | 0                |
| 46        | t_47_     | t_48_   | 47        | 1               | 47    | 0          | 0             | 0          | 0                    | 0                |
| 48        | t_48_     |         | 49        | 1               | 49    | 0          | 0             | 0          | 0                    | 0                |
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+

In this PR, every partition of the table will have 4 regions.

>show table t regions;
+-----------+----------------------------+----------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY                  | END_KEY                    | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+----------------------------+----------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| 44        | t_46_                      | t_46_r_2305843009213693952 | 45        | 1               | 45    | 0          | 0             | 0          | 0                    | 0                |
| 46        | t_46_r_2305843009213693952 | t_46_r_4611686018427387904 | 47        | 1               | 47    | 0          | 0             | 0          | 0                    | 0                |
| 48        | t_46_r_4611686018427387904 | t_46_r_6917529027641081856 | 49        | 1               | 49    | 0          | 0             | 0          | 0                    | 0                |
| 50        | t_46_r_6917529027641081856 | t_47_                      | 51        | 1               | 51    | 0          | 0             | 0          | 0                    | 0                |
| 52        | t_47_                      | t_47_r_2305843009213693952 | 53        | 1               | 53    | 0          | 0             | 0          | 0                    | 0                |
| 54        | t_47_r_2305843009213693952 | t_47_r_4611686018427387904 | 55        | 1               | 55    | 0          | 0             | 0          | 0                    | 0                |
| 56        | t_47_r_4611686018427387904 | t_47_r_6917529027641081856 | 57        | 1               | 57    | 0          | 0             | 0          | 0                    | 0                |
| 58        | t_47_r_6917529027641081856 | t_48_                      | 59        | 1               | 59    | 0          | 0             | 0          | 0                    | 0                |
| 60        | t_48_                      | t_48_r_2305843009213693952 | 61        | 1               | 61    | 0          | 0             | 0          | 0                    | 0                |
| 62        | t_48_r_2305843009213693952 | t_48_r_4611686018427387904 | 63        | 1               | 63    | 0          | 0             | 0          | 0                    | 0                |
| 64        | t_48_r_4611686018427387904 | t_48_r_6917529027641081856 | 65        | 1               | 65    | 0          | 0             | 0          | 0                    | 0                |
| 66        | t_48_r_6917529027641081856 |                            | 67        | 1               | 67    | 0          | 0             | 0          | 0                    | 0                |
+-----------+----------------------------+----------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+kk

What is changed and how it works?

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

  • No

Release note

  • Fix issue pre_split_regions table option doesn't work in the partition table.

Signed-off-by: crazycs520 <crazycs520@gmail.com>
@crazycs520 crazycs520 added type/bugfix This PR fixes a bug. sig/sql-infra SIG: SQL Infra labels Jun 19, 2020
@crazycs520 crazycs520 requested a review from a team as a code owner June 19, 2020 13:54
@crazycs520 crazycs520 requested review from SunRunAway and removed request for a team June 19, 2020 13:54
@github-actions github-actions bot added the sig/execution SIG execution label Jun 19, 2020
Copy link
Member

@wjhuang2016 wjhuang2016 left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Jun 28, 2020

Codecov Report

Merging #18144 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #18144   +/-   ##
===========================================
  Coverage   79.6450%   79.6450%           
===========================================
  Files           535        535           
  Lines        145100     145100           
===========================================
  Hits         115565     115565           
  Misses        20261      20261           
  Partials       9274       9274           

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot
Copy link
Contributor

@zimulala,Thanks for you review.

@zimulala zimulala added the status/can-merge Indicates a PR has been approved by a committer. label Jun 28, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@crazycs520 merge failed.

@crazycs520 crazycs520 merged commit 33f4b82 into pingcap:master Jun 29, 2020
@crazycs520 crazycs520 deleted the pre-split-partition branch June 29, 2020 06:04
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 28, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #18837

SunRunAway pushed a commit that referenced this pull request Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pre_split_regions doesn't work with partition table
4 participants