TiDB adding partition is particularly slow, taking hundreds of seconds without returning a result

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb add partition 特别慢,几百秒没返回结果

| username: qiuxb

[TiDB Usage Environment] Production Environment / Testing / Poc
Production Environment
[TiDB Version]
v.4.0.8
[Reproduction Path] What operations were performed when the issue occurred
There are 4 tables that need to add a one-year daily partition (365).
After deleting the historical partitions for 2020 and 2021, execute add partition.
The first two tables were very quick, taking about 1 second to add a partition, but the last two tables got stuck when adding partitions.
Execute alter table xxx add partition (partition p20230921 values less than (1695312000));

[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]

| username: h5n1 | Original post link

admin show ddl jobs to check

| username: qiuxb | Original post link

| username: tidb菜鸟一只 | Original post link

Do the top three tables have TiFlash replicas?

| username: qiuxb | Original post link

The table at the top that is running has TiFlash replicas.

| username: tidb菜鸟一只 | Original post link

There are quite a few issues with TiFlash regarding partitioned tables.

| username: qiuxb | Original post link

Is this the only way to force it to run? But it feels strange that it never returns a result.

| username: tidb菜鸟一只 | Original post link

It is estimated that the result cannot be obtained… If possible, remove the TiFlash replica, add the partition, and then add the TiFlash replica again?

| username: TiDBer_oHSwKxOH | Original post link

Your DDL is also stuck, you need to restart the TiDB service.

| username: h5n1 | Original post link

Check if there is relevant information about this table in the TiFlash logs.

| username: qiuxb | Original post link

[2023/09/19 17:00:59.079 +08:00] [INFO] [] [“SchemaBuilder: No partition changes DatabaseName(48).TableName(2235)”] [thread_id=432327449], there was such a log prompt at the beginning of the execution, but no new logs have been generated for 50 minutes.

| username: qiuxb | Original post link

To delete the replica in TiFlash, do I just need to execute the following command?
ALTER TABLE db.tablename SET TIFLASH REPLICA 0

| username: tidb菜鸟一只 | Original post link

Well, it should be executed like this, but your current DDL job is probably stuck, and you might need to restart the TiDB server.

| username: qiuxb | Original post link

I manually canceled the DDL job. After canceling the replica, the partitioning operation takes about 2 seconds each.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.