pingcap / pingcap/tidb

TiDB reports `Unknown partition ...` error when running the same `TRUNCATE PARTITION` stmt concurrently

Open
#45,111 1 comment 0 reactions 0 assignees View on GitHub
component/tablepartition sig/sql-infra type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Reproduction

Prepare:
```sql
use test;
create table t(a int, b int,c int) partition by range(a) (partition p1 values less than (100),partition p2 values less than (200),partition p3 values less than (300),partition p4 values less than maxvalue);
```

Connection 1:
```sql
alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;
```

Connection 2:
```sql
alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;alter table t truncate partition p1;
```

Execute the statements in connections 1 and 2 at the same time.

### Expected result:

all queries succeed eventually.

### Actual Result:

Connection 1:
```
Query OK, 0 rows affected (0.086 sec)

Query OK, 0 rows affected (0.091 sec)

Query OK, 0 rows affected (0.094 sec)

Query OK, 0 rows affected (0.092 sec)

Query OK, 0 rows affected (0.095 sec)

Query OK, 0 rows affected (0.087 sec)

Query OK, 0 rows affected (0.084 sec)
```
Connection 2:
```
Query OK, 0 rows affected (0.095 sec)

Query OK, 0 rows affected (0.086 sec)

Query OK, 0 rows affected (0.086 sec)

ERROR 1735 (HY000): Unknown partition 'pid:[105]' in table 't'
ERROR 1735 (HY000): Unknown partition 'pid:[108]' in table 't'
ERROR 1735 (HY000): Unknown partition 'pid:[111]' in table 't'
ERROR 1735 (HY000): Unknown partition 'pid:[114]' in table 't'
```

## Versions
Tested on v6.1.6 and v7.2.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.