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 lock doesn't work on the partition for subquery/joins #21618

Closed
bb7133 opened this issue Dec 9, 2020 · 4 comments
Closed

*: pessimistic lock doesn't work on the partition for subquery/joins #21618

bb7133 opened this issue Dec 9, 2020 · 4 comments
Labels
severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@bb7133
Copy link
Member

bb7133 commented Dec 9, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t (c_int int, d_int int, primary key (c_int), key(d_int)) partition by hash (c_int) partitions 4 ;
insert into t values (1, 2);

(session 1)
begin pessimistic;
select * from t where d_int in (select d_int from t where c_int = 1) for update;

(session 2)
begin pessimistic;
select * from t where d_int = 2 for update;

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

Session 1 and session 2 tries to acquire the lock for the same record, so one of them should be blocked and waited for the lock.

3. What did you see instead (Required)

Neither select ... for update is blocked.

4. What is your TiDB version? (Required)

I reproduced this bug in the latest master, but it should be reproduced in all existing releases that support pessimistic lock and (hash?) partitions.

5. Additional information

This bug is actually found when @blacktear23 trying to solve #21509, both of the bugs are caused by the same reason. You can check #21509 for more details.

@cfzjywxk
Copy link
Contributor

cfzjywxk commented Mar 22, 2021

@bb7133
Could the fix pr merged before 5.0 GA, or is there any risk to merge the fix?

@blacktear23
Copy link
Contributor

@bb7133
Could the fix pr merged before 5.0 GA, or is there any risk to merge the fix?

#21148
@cfzjywxk PTAL

@qw4990
Copy link
Contributor

qw4990 commented Jun 16, 2021

This issue can be solved by #21148.

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
7 participants