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

executor: split a separate region for index when split table region #11721

Merged
merged 9 commits into from
Aug 22, 2019

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Aug 13, 2019

What problem does this PR solve?

  • Split a separate region for index when splitting table region.
  • Split a separate region for the next index when splitting table index region.

before

create table t (a int,b int, index idxa(a), index idxb(b));
split table t between (0) and (10000) regions 2;

-- The key/value of index `idxa` and `idxb` will write into region 251. But User will think region 251 and region 3 are only used to store record kv.
show table t regions;
+-----------+-------------+-------------+-----------+-----------------+---------------+------------+
| REGION_ID | START_KEY   | END_Key     | LEADER_ID | LEADER_STORE_ID | PEERS         | SCATTERING |
+-----------+-------------+-------------+-----------+-----------------+---------------+------------+
| 251       | t_52_       | t_52_r_5000 | 254       | 6               | 254, 255, 256 | 0          |
| 3         | t_52_r_5000 |             | 134       | 6               | 4, 16, 134    | 0          |
+-----------+-------------+-------------+-----------+-----------------+---------------+------------+

split table t index idxa between (0) and (10000) regions 2;

-- The key/value of `idxb` and some part of index `idxa` will write into region 251.
show table t regions;
+-----------+-----------------------------------------+-----------------------------------------+-----------+-----------------+---------------+------------+
| REGION_ID | START_KEY                               | END_Key                                 | LEADER_ID | LEADER_STORE_ID | PEERS         | SCATTERING |
+-----------+-----------------------------------------+-----------------------------------------+-----------+-----------------+---------------+------------+
| 251       | t_52_i_1_038000000000001388030000000000 | t_52_r_5000                             | 254       | 6               | 254, 255, 256 | 0          |
| 3         | t_52_r_5000                             |                                         | 134       | 6               | 4, 16, 134    | 0          |
| 262       | t_52_i_1_                               | t_52_i_1_038000000000001388030000000000 | 266       | 1               | 264, 265, 266 | 0          |
+-----------+-----------------------------------------+-----------------------------------------+-----------+-----------------+---------------+------------+

In This PR

create table t (a int,b int, index idxa(a), index idxb(b));
split table t between (0) and (10000) regions 2;

-- The key/value of index `idxa` and `idxb` will write into region 271. Region 275 and region 3 is only used to store record key/values/
show table t regions;
+-----------+-------------+-------------+-----------+-----------------+---------------+------------+
| REGION_ID | START_KEY   | END_KEY     | LEADER_ID | LEADER_STORE_ID | PEERS         | SCATTERING |
+-----------+-------------+-------------+-----------+-----------------+---------------+------------+
| 275       | t_55_r      | t_55_r_5000 | 278       | 6               | 278, 279, 280 | 0          |
| 3         | t_55_r_5000 |             | 134       | 6               | 4, 16, 134    | 0          |
| 271       | t_55_       | t_55_r      | 274       | 6               | 272, 273, 274 | 0          |
+-----------+-------------+-------------+-----------+-----------------+---------------+------------+

split table t index idxa between (0) and (10000) regions 2;

-- The key/value of index `idxb` will write into region 271, region 291 and region 286 will only used to store index `idxa` key/values.
show table t regions;
+-----------+-----------------------------------------+-----------------------------------------+-----------+-----------------+---------------+------------+
| REGION_ID | START_KEY                               | END_KEY                                 | LEADER_ID | LEADER_STORE_ID | PEERS         | SCATTERING |
+-----------+-----------------------------------------+-----------------------------------------+-----------+-----------------+---------------+------------+
| 275       | t_55_r                                  | t_55_r_5000                             | 278       | 6               | 278, 279, 280 | 0          |
| 3         | t_55_r_5000                             |                                         | 16        | 2               | 4, 16, 134    | 0          |
| 291       | t_55_i_1_                               | t_55_i_1_038000000000001388030000000000 | 296       | 7               | 292, 295, 296 | 0          |
| 286       | t_55_i_1_038000000000001388030000000000 | t_55_i_2_                               | 289       | 6               | 288, 289, 290 | 0          |
| 271       | t_55_i_2_                               | t_55_r                                  | 274       | 6               | 272, 273, 274 | 0          |
+-----------+-----------------------------------------+-----------------------------------------+-----------+-----------------+---------------+------------+

What is changed and how it works?

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

Related changes

  • Need to cherry-pick to the release branch

@crazycs520 crazycs520 added type/usability type/enhancement The issue or PR belongs to an enhancement. labels Aug 13, 2019
@crazycs520
Copy link
Contributor Author

/run-all-tests

@codecov
Copy link

codecov bot commented Aug 13, 2019

Codecov Report

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

@@             Coverage Diff             @@
##             master     #11721   +/-   ##
===========================================
  Coverage   81.5092%   81.5092%           
===========================================
  Files           435        435           
  Lines         93955      93955           
===========================================
  Hits          76582      76582           
  Misses        11897      11897           
  Partials       5476       5476

@AilinKid AilinKid requested a review from bb7133 August 13, 2019 06:30
executor/executor_test.go Outdated Show resolved Hide resolved
@crazycs520
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

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

LGTM

@tangenta tangenta added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 20, 2019
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@bb7133 bb7133 added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 22, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Aug 22, 2019

/run-all-tests

@sre-bot sre-bot merged commit ddace4f into pingcap:master Aug 22, 2019
@crazycs520
Copy link
Contributor Author

/run-cherry-picker

@sre-bot
Copy link
Contributor

sre-bot commented Aug 29, 2019

cherry pick to release-2.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Aug 29, 2019

cherry pick to release-3.0 failed

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement. type/usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants