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

Pessimistic DML should not lock non-unique index keys #36235

Closed
ekexium opened this issue Jul 15, 2022 · 2 comments · Fixed by #36229
Closed

Pessimistic DML should not lock non-unique index keys #36235

ekexium opened this issue Jul 15, 2022 · 2 comments · Fixed by #36229
Labels
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 severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@ekexium
Copy link
Contributor

ekexium commented Jul 15, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(id varchar(40), v int, PRIMARY KEY (`id`) clustered, key i2(v))
insert into t values ('123', 1)
begin pessimistic
update t set v = v + 1 where id = '123'
commit

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

The update statement is not supposed to lock the index key.

3. What did you see instead (Required)

The update statement acquires a pessimistic lock for the index key.

4. What is your TiDB version? (Required)

master (987bdd3)

@ekexium ekexium added the type/bug The issue is confirmed as a bug. label Jul 15, 2022
@ekexium ekexium added severity/major 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. labels Jul 15, 2022
@ti-chi-bot ti-chi-bot added the may-affects-4.0 This bug maybe affects 4.0.x versions. label Jul 15, 2022
@seiya-annie seiya-annie added sig/transaction SIG:Transaction and removed sig/transaction SIG:Transaction labels Jul 15, 2022
@ekexium ekexium removed the may-affects-4.0 This bug maybe affects 4.0.x versions. label Jul 15, 2022
@cfzjywxk
Copy link
Contributor

cfzjywxk commented Aug 4, 2022

@ekexium

After this for such execution plans:

update uk = uk where sk = 1; // The uk value is not changed
The plan:
update
    select lock
        index look up 

The unique key could be locked but #25730 would not work so the LOCK record could accumulate and lead to performance issues.

/cc @you06 @MyonKeminta @sticnarf

@cfzjywxk
Copy link
Contributor

cfzjywxk commented Aug 5, 2022

@ekexium

After this for such execution plans:

update uk = uk where sk = 1; // The uk value is not changed
The plan:
update
    select lock
        index look up 

The unique key could be locked but #25730 would not work so the LOCK record could accumulate and lead to performance issues.

/cc @you06 @MyonKeminta @sticnarf

Sorry I've replied to the wrong issue. It should be #36438...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 severity/major 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.

5 participants