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

The mdl lock is not fully effective when multiple clients simultaneously truncate the table. #40484

Closed
bob34007 opened this issue Jan 11, 2023 · 1 comment · Fixed by #40501
Closed
Labels
affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@bob34007
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> desc test.t1;
+-------+---------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+------+---------+-------+
| id | int(11) | YES | | NULL | |
+-------+---------+------+------+---------+-------+
1 row in set (0.00 sec)
insert into test.t1 values (1),(2),(3);
session 1: begin; select * from test.t1 for update ;
session 2: truncate table test.t1;
session 3: truncate table test.t1;

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

session 2 and session 3 are both blocked by metadata lock

3. What did you see instead (Required)

session3 truncated data successfully

4. What is your TiDB version? (Required)

| Release Version: v6.5.0
Edition: Community
Git Commit Hash: 706c3fa
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 |

@benmaoer
Copy link

Metadata locks that already been held will block the following DDL operations. Session 2 & 3 are blocked by session 1

mysql> desc test.t1;
+-------+---------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+------+---------+-------+
| id | int(11) | YES | | NULL | |
+-------+---------+------+------+---------+-------+
1 row in set (0.00 sec)


insert into test.t1 values (1),(2),(3);
session 1: begin; select * from test.t1 for update ;
session 2: truncate table test.t1;
session 3: drop table test.t1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants