Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
- Create a table:
create table ht(a int, b varchar(10), index idx_b (b)) partition by hash(a) partitions 3;
- Insert some data:
insert into ht values (1, "a"), (2, "b"), (3, "c");
- Check the meta:
mysql> select * from mysql.stats_meta;
+--------------------+----------+--------------+-------+----------+
| version | table_id | modify_count | count | snapshot |
+--------------------+----------+--------------+-------+----------+
| 445359571104169990 | 103 | 1 | 1 | 0 |
| 445359571104169998 | 104 | 1 | 1 | 0 |
| 445359571104170003 | 105 | 1 | 1 | 0 |
| 445359571104170003 | 102 | 3 | 3 | 0 |
+--------------------+----------+--------------+-------+----------+
4 rows in set (0.00 sec)
- Decrease the partitions number to 2:
alter table ht partition by hash(a) partitions 2;
- Check the meta again:
mysql> select * from mysql.stats_meta;
+--------------------+----------+--------------+-------+----------+
| version | table_id | modify_count | count | snapshot |
+--------------------+----------+--------------+-------+----------+
| 445359865298681862 | 103 | 1 | 1 | 0 |
| 445359865298681870 | 104 | 1 | 1 | 0 |
| 445359865298681875 | 105 | 1 | 1 | 0 |
| 445359865298681875 | 109 | 3 | 3 | 0 |
| 445359872520486920 | 107 | 0 | 0 | 0 |
| 445359872520486923 | 108 | 0 | 0 | 0 |
+--------------------+----------+--------------+-------+----------+
6 rows in set (0.00 sec)
mysql> show stats_meta;
+---------+------------+----------------+---------------------+--------------+-----------+
| Db_name | Table_name | Partition_name | Update_time | Modify_count | Row_count |
+---------+------------+----------------+---------------------+--------------+-----------+
| test | ht | global | 2023-11-02 16:17:40 | 3 | 3 |
| test | ht | p0 | 2023-11-02 16:18:07 | 0 | 0 |
| test | ht | p1 | 2023-11-02 16:18:07 | 0 | 0 |
+---------+------------+----------------+---------------------+--------------+-----------+
3 rows in set (0.01 sec)
2. What did you expect to see? (Required)
- Drop the old stats.
3. What did you see instead (Required)
mysql> select * from mysql.stats_meta;
+--------------------+----------+--------------+-------+----------+
| version | table_id | modify_count | count | snapshot |
+--------------------+----------+--------------+-------+----------+
| 445359865298681862 | 103 | 1 | 1 | 0 |
| 445359865298681870 | 104 | 1 | 1 | 0 |
| 445359865298681875 | 105 | 1 | 1 | 0 |
| 445359865298681875 | 109 | 3 | 3 | 0 |
| 445359872520486920 | 107 | 0 | 0 | 0 |
| 445359872520486923 | 108 | 0 | 0 | 0 |
+--------------------+----------+--------------+-------+----------+
6 rows in set (0.00 sec)
4. What is your TiDB version? (Required)
mysql> select tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.6.0-alpha-69-gbf8c728934
Edition: Community
Git Commit Hash: bf8c728934c7376765ddd943fd302fcb65af4bf0
Git Branch: master
UTC Build Time: 2023-11-01 08:29:41
GoVersion: go1.21.1
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
create table ht(a int, b varchar(10), index idx_b (b)) partition by hash(a) partitions 3;insert into ht values (1, "a"), (2, "b"), (3, "c");alter table ht partition by hash(a) partitions 2;2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)