Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPLACE statement has unexpected behavior in concurrent transactions #42121

Closed
sayJason opened this issue Mar 12, 2023 · 1 comment · Fixed by #42210
Closed

REPLACE statement has unexpected behavior in concurrent transactions #42121

sayJason opened this issue Mar 12, 2023 · 1 comment · Fixed by #42210
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) severity/critical sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@sayJason
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

/* init */ CREATE TABLE t0(c0 DOUBLE UNIQUE);
/* init */ INSERT INTO t0(c0) VALUES (9.1);

/* tx1 */ BEGIN;
/* tx1 */ INSERT INTO t0(c0) VALUES (2.0);
/* tx1 */ REPLACE INTO t0(c0) VALUES (9.1);
/* tx2 */ BEGIN;
/* tx2 */ DELETE FROM t0;
/* tx2 */ COMMIT;
/* tx1 */ COMMIT;
/* tx1 */ SELECT * FROM t0;

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

DELETE statement is blocked (in MySQL), or the final SELECT statement returns [(2.0), (9.1)].

3. What did you see instead (Required)

The final SELECT statement returns [(2.0)].

4. What is your TiDB version? (Required)

Release Version: v6.6.0
Edition: Community
Git Commit Hash: f4ca0821fb96a2bdd37d2fb97eb26c07fc58d4e4
Git Branch: heads/refs/tags/v6.6.0
UTC Build Time: 2023-02-17 14:49:02
GoVersion: go1.19.5
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
@sayJason sayJason added the type/bug The issue is confirmed as a bug. label Mar 12, 2023
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels Mar 13, 2023
@zyguan
Copy link
Contributor

zyguan commented Mar 14, 2023

Thanks for your report, @sayJason . We forget to mark unchanged keys to be locked in replace, which leads to this bug.

@zyguan zyguan self-assigned this Mar 14, 2023
@zyguan zyguan added severity/moderate compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) severity/critical affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. and removed severity/critical severity/moderate may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.1 may-affects-6.5 labels Mar 14, 2023
@zyguan zyguan added affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 labels Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) severity/critical sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants