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

PRE_SPLIT_REGIONS doesn't work after TRUNCATE PARTITION operation #43028

Closed
zhenemola opened this issue Apr 13, 2023 · 0 comments · Fixed by #43271
Closed

PRE_SPLIT_REGIONS doesn't work after TRUNCATE PARTITION operation #43028

zhenemola opened this issue Apr 13, 2023 · 0 comments · Fixed by #43271
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug This issue is a bug.

Comments

@zhenemola
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `tt` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`) /*T![clustered_index] NONCLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T! SHARD_ROW_ID_BITS=4 PRE_SPLIT_REGIONS=3 */
PARTITION BY RANGE (`id`)
(PARTITION `p1` VALUES LESS THAN (10),
 PARTITION `p2` VALUES LESS THAN (20),
 PARTITION `p3` VALUES LESS THAN (MAXVALUE))
MySQL [test]> show table tt regions;
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-----------------------------------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY                   | END_KEY                     | LEADER_ID | LEADER_STORE_ID | PEERS                             | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-----------------------------------+------------+---------------+------------+----------------------+------------------+
|     19312 | t_263_                      | t_263_r_1152921504606846976 |     19313 |              15 | 19313, 19314, 19315, 19316, 19317 |          0 |             0 |          0 |                    1 |                0 |
|     19318 | t_263_r_1152921504606846976 | t_263_r_2305843009213693952 |     19319 |              15 | 19319, 19320, 19321, 19322, 19323 |          0 |             0 |          0 |                    1 |                0 |
|     19324 | t_263_r_2305843009213693952 | t_263_r_3458764513820540928 |     19325 |              15 | 19325, 19326, 19327, 19328, 19329 |          0 |             0 |          0 |                    1 |                0 |
|     19330 | t_263_r_3458764513820540928 | t_263_r_4611686018427387904 |     19331 |              15 | 19331, 19332, 19333, 19334, 19335 |          0 |             0 |          0 |                    1 |                0 |
|     19336 | t_263_r_4611686018427387904 | t_263_r_5764607523034234880 |     19337 |              15 | 19337, 19338, 19339, 19340, 19341 |          0 |             0 |          0 |                    1 |                0 |
|     19342 | t_263_r_5764607523034234880 | t_263_r_6917529027641081856 |     19343 |              15 | 19343, 19344, 19345, 19346, 19347 |          0 |             0 |          0 |                    1 |                0 |
|     19348 | t_263_r_6917529027641081856 | t_263_r_8070450532247928832 |     19349 |              15 | 19349, 19350, 19351, 19352, 19353 |          0 |             0 |          0 |                    1 |                0 |
|     19294 | t_263_r_8070450532247928832 | t_264_                      |     19295 |              15 | 19295, 19296, 19297, 19298, 19299 |          0 |            27 |          0 |                    1 |                0 |
|     19360 | t_264_                      | t_264_r_1152921504606846976 |     19361 |              15 | 19361, 19362, 19363, 19364, 19365 |          0 |             0 |          0 |                    1 |                0 |
|     19366 | t_264_r_1152921504606846976 | t_264_r_2305843009213693952 |     19367 |              15 | 19367, 19368, 19369, 19370, 19371 |          0 |             0 |          0 |                    1 |                0 |
|     19372 | t_264_r_2305843009213693952 | t_264_r_3458764513820540928 |     19373 |              15 | 19373, 19374, 19375, 19376, 19377 |          0 |             0 |          0 |                    1 |                0 |
|     19378 | t_264_r_3458764513820540928 | t_264_r_4611686018427387904 |     19379 |              15 | 19379, 19380, 19381, 19382, 19383 |          0 |             0 |          0 |                    1 |                0 |
|     19384 | t_264_r_4611686018427387904 | t_264_r_5764607523034234880 |     19385 |              15 | 19385, 19386, 19387, 19388, 19389 |          0 |             0 |          0 |                    1 |                0 |
|     19390 | t_264_r_5764607523034234880 | t_264_r_6917529027641081856 |     19391 |              15 | 19391, 19392, 19393, 19394, 19395 |          0 |             0 |          0 |                    1 |                0 |
|     19396 | t_264_r_6917529027641081856 | t_264_r_8070450532247928832 |     19397 |              15 | 19397, 19398, 19399, 19400, 19401 |          0 |             0 |          0 |                    1 |                0 |
|     19300 | t_264_r_8070450532247928832 | t_265_                      |     19301 |              15 | 19301, 19302, 19303, 19304, 19305 |          0 |            27 |          0 |                    1 |                0 |
|     19402 | t_265_                      | t_265_r_1152921504606846976 |     19403 |              15 | 19403, 19404, 19405, 19406, 19407 |          0 |             0 |          0 |                    1 |                0 |
|     19408 | t_265_r_1152921504606846976 | t_265_r_2305843009213693952 |     19409 |              15 | 19409, 19410, 19411, 19412, 19413 |          0 |             0 |          0 |                    1 |                0 |
|     19414 | t_265_r_2305843009213693952 | t_265_r_3458764513820540928 |     19415 |              15 | 19415, 19416, 19417, 19418, 19419 |          0 |             0 |          0 |                    1 |                0 |
|     19420 | t_265_r_3458764513820540928 | t_265_r_4611686018427387904 |     19421 |              15 | 19421, 19422, 19423, 19424, 19425 |          0 |             0 |          0 |                    1 |                0 |
|     19426 | t_265_r_4611686018427387904 | t_265_r_5764607523034234880 |     19427 |              15 | 19427, 19428, 19429, 19430, 19431 |          0 |             0 |          0 |                    1 |                0 |
|     19432 | t_265_r_5764607523034234880 | t_265_r_6917529027641081856 |     19433 |              15 | 19433, 19434, 19435, 19436, 19437 |          0 |             0 |          0 |                    1 |                0 |
|     19438 | t_265_r_6917529027641081856 | t_265_r_8070450532247928832 |     19439 |              15 | 19439, 19440, 19441, 19442, 19443 |          0 |             0 |          0 |                    1 |                0 |
|     19306 | t_265_r_8070450532247928832 | t_266_                      |     19307 |              15 | 19307, 19308, 19309, 19310, 19311 |          0 |            27 |          0 |                    1 |                0 |
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-----------------------------------+------------+---------------+------------+----------------------+------------------+
24 rows in set (0.04 sec)

MySQL [test]> alter table tt truncate partition p3;

2. What did you expect to see? (Required)

show table tt regions command displays 24 regions

3. What did you see instead (Required)

MySQL [test]> show table tt regions;
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-----------------------------------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY                   | END_KEY                     | LEADER_ID | LEADER_STORE_ID | PEERS                             | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-----------------------------------+------------+---------------+------------+----------------------+------------------+
|     19312 | t_263_                      | t_263_r_1152921504606846976 |     19313 |              15 | 19313, 19314, 19315, 19316, 19317 |          0 |             0 |          0 |                    1 |                0 |
|     19318 | t_263_r_1152921504606846976 | t_263_r_2305843009213693952 |     19319 |              15 | 19319, 19320, 19321, 19322, 19323 |          0 |             0 |          0 |                    1 |                0 |
|     19324 | t_263_r_2305843009213693952 | t_263_r_3458764513820540928 |     19325 |              15 | 19325, 19326, 19327, 19328, 19329 |          0 |             0 |          0 |                    1 |                0 |
|     19330 | t_263_r_3458764513820540928 | t_263_r_4611686018427387904 |     19331 |              15 | 19331, 19332, 19333, 19334, 19335 |          0 |             0 |          0 |                    1 |                0 |
|     19336 | t_263_r_4611686018427387904 | t_263_r_5764607523034234880 |     19337 |              15 | 19337, 19338, 19339, 19340, 19341 |          0 |             0 |          0 |                    1 |                0 |
|     19342 | t_263_r_5764607523034234880 | t_263_r_6917529027641081856 |     19343 |              15 | 19343, 19344, 19345, 19346, 19347 |          0 |             0 |          0 |                    1 |                0 |
|     19348 | t_263_r_6917529027641081856 | t_263_r_8070450532247928832 |     19353 |              17 | 19349, 19350, 19351, 19352, 19353 |          0 |             0 |          0 |                    1 |                0 |
|     19294 | t_263_r_8070450532247928832 | t_264_                      |     19295 |              15 | 19295, 19296, 19297, 19298, 19299 |          0 |             0 |          0 |                    1 |                0 |
|     19360 | t_264_                      | t_264_r_1152921504606846976 |     19361 |              15 | 19361, 19362, 19363, 19364, 19365 |          0 |             0 |          0 |                    1 |                0 |
|     19366 | t_264_r_1152921504606846976 | t_264_r_2305843009213693952 |     19367 |              15 | 19367, 19368, 19369, 19370, 19371 |          0 |             0 |          0 |                    1 |                0 |
|     19372 | t_264_r_2305843009213693952 | t_264_r_3458764513820540928 |     19373 |              15 | 19373, 19374, 19375, 19376, 19377 |          0 |             0 |          0 |                    1 |                0 |
|     19378 | t_264_r_3458764513820540928 | t_264_r_4611686018427387904 |     19379 |              15 | 19379, 19380, 19381, 19382, 19383 |          0 |             0 |          0 |                    1 |                0 |
|     19384 | t_264_r_4611686018427387904 | t_264_r_5764607523034234880 |     19385 |              15 | 19385, 19386, 19387, 19388, 19389 |          0 |             0 |          0 |                    1 |                0 |
|     19390 | t_264_r_5764607523034234880 | t_264_r_6917529027641081856 |     19395 |              17 | 19391, 19392, 19393, 19394, 19395 |          0 |            39 |          0 |                    1 |                0 |
|     19396 | t_264_r_6917529027641081856 | t_264_r_8070450532247928832 |     19397 |              15 | 19397, 19398, 19399, 19400, 19401 |          0 |             0 |          0 |                    1 |                0 |
|     19300 | t_264_r_8070450532247928832 | t_265_                      |     19301 |              15 | 19301, 19302, 19303, 19304, 19305 |          0 |             0 |          0 |                    1 |                0 |
|     19450 | t_267_                      | t_268_                      |     19451 |              15 | 19451, 19452, 19453, 19454, 19455 |          0 |             0 |          0 |                    1 |                0 |
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-----------------------------------+------------+---------------+------------+----------------------+------------------+
17 rows in set (0.04 sec)

4. What is your TiDB version? (Required)

MySQL [test]> SELECT tidb_version();
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                                           |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.1.2-20230301
Edition: Enterprise
Git Commit Hash: 38e7d898f2128dc3dd8324f44b6a8586f0e93106
Git Branch: heads/refs/tags/v6.1.2-20230301
UTC Build Time: 2023-03-01 08:51:06
GoVersion: go1.18.10
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants