pingcap / pingcap/tidb

The table is not locked with a writer lock, but the query result shows that it has been locked with a writer lock.

Open
#60,019 1 comment 0 reactions 0 assignees View on GitHub
sig/transaction type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

The table is not locked with a writer lock, but the query result shows that it has been locked with a writer lock.

### 1. Minimal reproduce step (Required)

```

1. Set the config variable enable-table-lock to true.
2. Session_1:
BEGIN;
UPDATE table_a SET id = id + 1;
-- Note: Do not commit the transaction.
3. Session_2:
LOCK TABLE table_a WRITE;
-- Since Session_1's transaction is not committed, it will be waiting to acquire the MDL lock here.
4. Session_3:
SELECT * FROM table_a LIMIT 1; Returns ERROR 8020 (HY000): Table 'table_a' was locked in WRITE by server: d2ddf8d9-8914-43c3-a289-da56d213ff72_session: 2942307816.
However, in fact, table_a is still waiting to acquire the MDL lock in step 3 and has not successfully locked yet.

```
### 2. What did you expect to see? (Required)
It should not return a result, but instead keep waiting to acquire the MDL lock.
### 3. What did you see instead (Required)
It immediately returned ERROR 8020 (HY000): Table 'table_a' was locked in WRITE by server: d2ddf8d9-8914-43c3-a289-da56d213ff72_session: 2942307816
### 4. What is your TiDB version? (Required)
v8.5.1

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.