pingcap / pingcap/tidb

Concurrent execution of change column statements by multiple sessions will lead to the appearance of the same row.

Open
#60,261 2 comments 0 reactions 1 assignee Claimed by @CbcWestwolf View on GitHub
affects-8.5 component/ddl impact/inconsistency type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

deploy tidb:

```
tiup playground v8.5.1 --host 0.0.0.0
```

Four sessions concurrently running change column DDL:

```sql
-- session 1
alter table table0 change commonAttr2_0 commonAttr2_0 decimal(10, 2);

-- session 2
alter table table0 change commonAttr2_0 commonAttr2_0 decimal(10, 2);

-- session 3
alter table table0 change commonAttr3_0 commonAttr3_0 decimal(10, 2);

-- session 4
alter table table0 change commonAttr4_0 commonAttr4_0 decimal(10, 2);
```

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

After all workloads:

```sql
mysql> admin check table table0;
-- ok
```

### 3. What did you see instead (Required)

After all workloads:

```sql
mysql> admin check table table0;
ERROR 8223 (HY000): data inconsistency in table: table0, index: table0index_commAttr2, handle: 13, index-values:"handle: 13, values: [KindMysqlDecimal 61.00]" != record-values:"handle: 13, values: [KindMysqlDecimal 63.00]"
```

```sql
mysql> select * from table0 force index(table0index_commAttr2) order by pkId;
+------+---------+---------------+---------------+---------------+---------------+---------------+
| pkId | pkAttr0 | commonAttr0_0 | commonAttr1_0 | commonAttr2_0 | commonAttr3_0 | commonAttr4_0 |
+------+---------+---------------+---------------+---------------+---------------+---------------+
| 0 | 2 | 89 | 89 | 89.00 | 89.00 | 89.00 |
| 1 | 10 | 84 | 84 | 84.00 | 84.00 | 84.00 |
| 2 | 14 | 7 | 56 | 56.00 | 56.00 | 56.00 |
| 3 | 27 | 89 | 89 | 4.00 | 89.00 | 89.00 |
| 4 | 30 | 4 | 4 | 4.00 | 4.00 | 4.00 |
| 5 | 39 | 56 | 56 | 56.00 | 56.00 | 56.00 |
| 6 | 47 | 59 | 78 | 84.00 | 59.00 | 59.00 |
| 7 | 54 | 56 | 56 | 56.00 | 56.00 | 56.00 |
| 8 | 60 | 0 | 0 | 0.00 | 0.00 | 0.00 |
| 9 | 67 | 1 | 1 | 1.00 | 1.00 | 1.00 |
| 10 | 76 | 0 | 0 | 0.00 | 0.00 | 0.00 |
| 11 | 82 | 16 | 16 | 16.00 | 16.00 | 16.00 |
| 12 | 88 | 93 | 21 | 63.00 | 62.00 | 38.00 |
| 12 | 88 | 93 | 21 | 63.00 | 62.00 | 38.00 |
| 13 | 95 | 71 | 71 | 71.00 | 71.00 | 71.00 |
| 14 | 104 | 33 | 33 | 33.00 | 33.00 | 33.00 |
| 15 | 110 | 63 | 63 | 63.00 | 63.00 | 63.00 |
| 16 | 115 | 65 | 65 | 65.00 | 65.00 | 65.00 |
| 17 | 123 | 7 | 7 | 7.00 | 7.00 | 7.00 |
| 18 | 132 | 10 | 4 | 96.00 | 4.00 | 4.00 |
| 19 | 138 | 1 | 1 | 18.00 | 18.00 | 83.00 |
| 20 | 143 | 4 | 4 | 4.00 | 4.00 | 4.00 |
| 21 | 149 | 20 | 27 | 60.00 | 3.00 | 20.00 |
| 22 | 160 | 53 | 53 | 53.00 | 53.00 | 53.00 |
| 23 | 161 | 78 | 78 | 78.00 | 78.00 | 78.00 |
| 24 | 171 | 7 | 7 | 7.00 | 7.00 | 7.00 |
| 25 | 177 | 61 | 61 | 61.00 | 61.00 | 61.00 |
| 26 | 188 | 27 | 27 | 27.00 | 27.00 | 27.00 |
| 27 | 189 | 40 | 9 | 9.00 | 51.00 | 27.00 |
| 28 | 199 | 3 | 3 | 3.00 | 3.00 | 3.00 |
| 29 | 208 | 0 | 0 | 0.00 | 0.00 | 0.00 |
+------+---------+---------------+---------------+---------------+---------------+---------------+
31 rows in set (0.00 sec)
```

**Two rows with the same content appeared. For example, pkId = 12**

### 4. What is your TiDB version? (Required)

TiDB v8.5.1

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.