pingcap / pingcap/tidb

One pessimistic txn should show one row in DATA_LOCK_WAITS

Open
#60,227 1 comment 0 reactions 1 assignee Claimed by @zyguan View on GitHub
duplicate type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
```
drop table a;
CREATE TABLE `a` (
id int,
value int
);

insert into a values(1,1);
insert into a values(2,2);
insert into a values(3,3);
commit;

session1
begin;
update a set value=4 where id=1;

session2;
begin; //非autocommit的悲观事务
update a set value=24 where id=1;

session3;
select * from information_schema.DATA_LOCK_WAITS;

+----------------------------------------+-----------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------+
| KEY | KEY_INFO | TRX_ID | CURRENT_HOLDING_TRX_ID | SQL_DIGEST | SQL_DIGEST_TEXT |
+----------------------------------------+-----------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------+
| 7480000000000000775F728000000000000001 | {"db_name":"test","table_name":"a","handle_type":"int","handle_value":"1","db_id":2,"table_id":119} | 456781725640949761 | 456781724251324417 | d7ed53e1832a8e5a7adafada41cb3d910d3681c4e2a6650f46d851c5b278e257 | update `a` set value = ? where `id` = ? |
| 7480000000000000775F728000000000000001 | {"db_name":"test","table_name":"a","handle_type":"int","handle_value":"1","db_id":2,"table_id":119} | 456781725640949761 | 456781724251324417 | NULL | NULL |
+----------------------------------------+-----------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------+
2 rows in set (0.00 sec)
```

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

### 3. What did you see instead (Required)
```
mysql> select * from information_schema.DATA_LOCK_WAITS;
+----------------------------------------+-----------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------+
| KEY | KEY_INFO | TRX_ID | CURRENT_HOLDING_TRX_ID | SQL_DIGEST | SQL_DIGEST_TEXT |
+----------------------------------------+-----------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------+
| 74800000000000006E5F728000000000000001 | {"db_name":"test","table_name":"a","handle_type":"int","handle_value":"1","db_id":2,"table_id":110} | 456859482449510401 | 456859477481619458 | d7ed53e1832a8e5a7adafada41cb3d910d3681c4e2a6650f46d851c5b278e257 | update `a` set value = ? where `id` = ? |
| 74800000000000006E5F728000000000000001 | {"db_name":"test","table_name":"a","handle_type":"int","handle_value":"1","db_id":2,"table_id":110} | 456859482449510401 | 456859477481619458 | NULL | NULL |
| 74800000000000006E5F728000000000000001 | {"db_name":"test","table_name":"a","handle_type":"int","handle_value":"1","db_id":2,"table_id":110} | 456859676107866113 | 456859477481619458 | NULL | NULL |
+----------------------------------------+-----------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------+
3 rows in set (0.01 sec)
```

### 4. What is your TiDB version? (Required)
>= v6.5

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.