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) #18837

Merged
merged 4 commits into from
Jul 29, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #18144 to release-4.0


Signed-off-by: crazycs520 [email protected]

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.

@ti-srebot
Copy link
Contributor Author

/run-all-tests

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

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 29, 2020
Copy link
Contributor

@AilinKid AilinKid 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 ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 29, 2020
@crazycs520
Copy link
Contributor

/run-all-tests

@crazycs520
Copy link
Contributor

/run-integration-copr-test

@crazycs520
Copy link
Contributor

/run-unit-test

@SunRunAway SunRunAway merged commit 3c74fec into pingcap:release-4.0 Jul 29, 2020
@crazycs520 crazycs520 deleted the release-4.0-33f4b82166ad branch July 29, 2020 05:35
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/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants