pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.28k stars 5.84k forks source link

not triagge auto analyze after reorganize partition table #48836

Closed aytrack closed 6 months ago

aytrack commented 11 months ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. create partition table and insert some data
  2. reorganize partition table like
    alter table xxx.xxx reorganize partition p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,p31,p32,p33,p34,p35,p36,p37,p38,p39,p40,p41,p42,p43,p44,p45,p46,p47,p48,p49,p50,p51,p52,p53,p54,p55,p56,p57,p58,p59,p60,p61 into (partition pnew values less than ('2023-03-13'))

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

triagge auto analyze and stats_meta will be correct

3. What did you see instead (Required)

you can see reorganize partition is finished at 2023-03-13 12:07:48, but after about 14 hours, there is still has now the pnew partition stats meta info.

[10:12:59]TiDB root:xxx> admin show ddl jobs;
+--------+---------+----------------------+----------------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+
| JOB_ID | DB_NAME | TABLE_NAME           | JOB_TYPE                         | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME         | START_TIME          | END_TIME            | STATE     |
+--------+---------+----------------------+----------------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+
| 789    | xxx    | xxx | alter table reorganize partition | none         | 718       | 720      | 11942928  | 2023-03-13 12:44:54 | 2023-03-13 12:44:54 | 2023-03-13 12:58:49 | synced    |
| 787    | xxx    | xxx         | create table                     | public       | 718       | 786      | 0         | 2023-03-13 12:07:47 | 2023-03-13 12:07:47 | 2023-03-13 12:07:48 | synced    |
| 785    | xxx    | xxx | create table                     | public       | 718       | 720      | 0         | 2023-03-13 12:07:47 | 2023-03-13 12:07:47 | 2023-03-13 12:07:47 | synced    |
| 719    | xxx    |                      | create schema                    | public       | 718       | 0        | 0         | 2023-03-13 12:07:47 | 2023-03-13 12:07:47 | 2023-03-13 12:07:47 | synced    |
| 717    | xxx    |                      | drop schema                      | none         | 518       | 0        | 0         | 2023-03-13 12:05:20 | 2023-03-13 12:05:20 | 2023-03-13 12:05:20 | synced    |
| 716    | test    | t1                   | create table                     | public       | 98        | 713      | 0         | 2023-03-13 11:53:24 | 2023-03-13 11:53:24 | 2023-03-13 11:53:24 | synced    |
| 712    | test    | t1                   | drop table                       | none         | 98        | 676      | 0         | 2023-03-13 11:53:23 | 2023-03-13 11:53:23 | 2023-03-13 11:53:23 | synced    |
| 711    |         |                      | flashback cluster                | delete only  | 0         | 0        | 0         | 2023-03-13 10:59:18 | 2023-03-13 10:59:18 | 2023-03-13 10:59:18 | cancelled |
| 710    | xxx    | xxx | alter table reorganize partition | none         | 518       | 520      | 44997324  | 2023-03-13 10:05:25 | 2023-03-13 10:05:25 | 2023-03-13 10:59:18 | synced    |
| 708    | test    | t4                   | alter table reorganize partition | none         | 98        | 694      | 0         | 2023-03-13 09:44:58 | 2023-03-13 09:44:58 | 2023-03-13 09:44:59 | synced    |
+--------+---------+----------------------+----------------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+
[10:23:18]TiDB root:xxx> show stats_meta where table_name = "xxx";
+---------+----------------------+----------------+---------------------+--------------+-----------+
| Db_name | Table_name           | Partition_name | Update_time         | Modify_count | Row_count |
+---------+----------------------+----------------+---------------------+--------------+-----------+
| xxx    | xxx | global         | 2023-03-13 13:01:42 | 799          | 1000800   |
| xxx    | xxx | p62            | 2023-03-13 12:30:10 | 0            | 5556      |
| xxx    | xxx | p63            | 2023-03-13 12:30:01 | 0            | 0         |
| xxx    | xxx | p64            | 2023-03-13 12:30:06 | 0            | 0         |
+---------+----------------------+----------------+---------------------+--------------+-----------+
4 rows in set
Time: 0.050s
[10:23:22]TiDB root:xxx> select now();
+---------------------+
| now()               |
+---------------------+
| 2023-03-14 02:23:22 |
+---------------------+
1 row in set
Time: 0.053s
[10:24:48]TiDB root:xxx> show analyze status;
+--------------+----------------------+----------------+------------------------------------------------------------------------------------+----------------+---------------------+---------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------+------------+
| Table_schema | Table_name           | Partition_name | Job_info                                                                           | Processed_rows | Start_time          | End_time            | State    | Fail_reason                                                                                                                     | Instance                                                       | Process_ID |
+--------------+----------------------+----------------+------------------------------------------------------------------------------------+----------------+---------------------+---------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------+------------+
| xxx         | xxx |                | merge global stats for xxx.xxx's index idx_ssmx_bill_detail_h010 | 0              | 2023-03-13 13:02:29 | 2023-03-13 13:02:31 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index idx_ssmx_bill_detail_h008 | 0              | 2023-03-13 13:02:25 | 2023-03-13 13:02:27 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index idx_ssmx_bill_detail_h007 | 0              | 2023-03-13 13:02:21 | 2023-03-13 13:02:23 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index primary                   | 0              | 2023-03-13 13:02:15 | 2023-03-13 13:02:18 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx columns                           | 0              | 2023-03-13 13:02:07 | 2023-03-13 13:02:09 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index xxx | 0              | 2023-03-13 13:02:03 | 2023-03-13 13:02:05 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index idx_xxx_h012 | 0              | 2023-03-13 13:02:00 | 2023-03-13 13:02:01 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index idx_xxx_h014 | 0              | 2023-03-13 13:01:56 | 2023-03-13 13:01:58 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index idx_xxx_h013 | 0              | 2023-03-13 13:01:52 | 2023-03-13 13:01:54 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index idx_xxx_i004 | 0              | 2023-03-13 13:01:48 | 2023-03-13 13:01:50 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index idx_xxx_i003 | 0              | 2023-03-13 13:01:44 | 2023-03-13 13:01:46 | failed   | [types:8131]Build global-level stats failed due to missing partition-level stats: table `xxx` partition `pnew` | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |
| xxx         | xxx |                | merge global stats for xxx.xxx's index xxx | 0              | 2023-03-13 12:58:41 | 2023-03-13 13:01:42 | finished | <null>                                                                                                                          | upstream-tidb-0.upstream-tidb-peer.utf-sql-toolswwgp9.svc:4000 | <null>     |

4. What is your TiDB version? (Required)

[10:25:44]TiDB root:xxx> select tidb_version();
+-----------------------------------------------------------+
| tidb_version()                                            |
+-----------------------------------------------------------+
| Release Version: v6.7.0-alpha                             |
| Edition: Community                                        |
| Git Commit Hash: 145b7cdf72feeecf7f2b0b3e01693c603712dce5 |
| Git Branch: heads/refs/tags/v6.7.0-alpha                  |
| UTC Build Time: 2023-03-11 11:42:07                       |
| GoVersion: go1.20.2                                       |
| Race Enabled: false                                       |
| TiKV Min Version: 6.2.0-alpha                             |
| Check Table Before Drop: false                            |
| Store: tikv                                               |
aytrack commented 11 months ago

from bb7133: I believe the root cause of this issue is the same with #48838

bb7133 commented 6 months ago

Closed by #42523