pingcap / pingcap/tidb

Return deleted record in repeatable-read transaction

Open
#44,379 1 comment 0 reactions 0 assignees View on GitHub
severity/moderate sig/transaction 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)

init
```mysql
create table t0 (a int);
insert into t0 values (1);
insert into t0 values (2);
```

Then run:
```mysql
session1 > begin;
session2 > begin;
session2 > delete from t0 where a=1;
session1 > delete from t0 where a=2;
session2 > commit; -- successful
session1 > select * from t0 where a=1; -- return (1)
```

This is not compatible with MySQL(for both 5.7.41 and 8.0.33), the behaviour of MySQL is:

```mysql
session1 > begin;
session2 > begin;
session2 > delete from t0 where a=1;
session1 > delete from t0 where a=2; -- blocked util session2 commit
session2 > commit; -- successful
session1 > select * from t0 where a=1; -- return empty set
```

Though the unblock of `delete from t0 where a=2;` in session1 is mentioned in doc[1]. But the followed commit is success (unlike the differ said in doc), and the follow incompatible select is also unmentioned.

[1]https://docs.pingcap.com/zh/tidb/v6.5/pessimistic-transaction

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

```
| Release Version: v6.5.0
Edition: Community
Git Commit Hash: 706c3fa3c526cdba5b3e9f066b1a568fb96c56e3
Git Branch: heads/refs/tags/v6.5.0
UTC Build Time: 2022-12-27 03:50:44
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
```

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.