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

truncate partition will not split a new region when tidb_scatter_region is on #43174

Closed
lcwangchao opened this issue Apr 19, 2023 · 0 comments · Fixed by #43271
Closed

truncate partition will not split a new region when tidb_scatter_region is on #43174

lcwangchao opened this issue Apr 19, 2023 · 0 comments · Fixed by #43271
Assignees
Labels
affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@lcwangchao
Copy link
Collaborator

lcwangchao commented Apr 19, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set @@global.tidb_scatter_region='ON';
CREATE TABLE tp (id int, c varchar(128), key c(c)) partition by range (id) (partition p0 values less than (10), partition p1 values less than MAXVALUE);
show table tp regions;
alter table tp truncate partition p0;
show table tp regions;

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

There will be at least two regions for table tp after tuncate partition.

3. What did you see instead (Required)

after create table:

TiDB root@127.0.0.1:test> show table tp 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 |
+-----------+-----------+----------+-----------+-----------------+------------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
| 2549      | t_177_    | t_178_   | 2551      | 2               | 2551       | 0          | 121           | 0          | 1                    | 0                |                        |                  |
| 2516      | t_178_    | 78000000 | 2517      | 1               | 2517, 2552 | 0          | 0             | 0          | 1                    | 346              |                        |                  |
+-----------+-----------+----------+-----------+-----------------+------------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
2 rows in set
Time: 0.009s

after truncate partition p0

TiDB root@127.0.0.1:test> show table tp 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 |
+-----------+-----------+----------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
| 2516      | t_178_    | 78000000 | 2552      | 2               | 2552  | 0          | 115           | 0          | 1                    | 0                |                        |                  |
+-----------+-----------+----------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+------------------------+------------------+
1 row in set
Time: 0.006s

There is only one region left.

4. What is your TiDB version? (Required)

TiDB root@127.0.0.1:test> select tidb_version();
+-----------------------------------------------------------+
| tidb_version()                                            |
+-----------------------------------------------------------+
| Release Version: v7.1.0-alpha                             |
| Edition: Community                                        |
| Git Commit Hash: 8e7ebb330fd8152f7b7a3db84ee77e72c1078a30 |
| Git Branch: heads/refs/tags/v7.1.0-alpha                  |
| UTC Build Time: 2023-04-17 14:26:49                       |
| GoVersion: go1.20.3                                       |
| Race Enabled: false                                       |
| TiKV Min Version: 6.2.0-alpha                             |
| Check Table Before Drop: false                            |
| Store: tikv                                               |
+-----------------------------------------------------------+
1 row in set
Time: 0.002s
@ti-chi-bot ti-chi-bot added may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. labels Apr 19, 2023
@mjonss mjonss added affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. and removed may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. labels May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants