暂无图片
mysql死锁只能打印最后引起锁等待的2条语句,其实一共执行了4条语句,有办法能显示全部的4条吗?
我来答
分享
暂无图片 匿名用户
mysql死锁只能打印最后引起锁等待的2条语句,其实一共执行了4条语句,有办法能显示全部的4条吗?

mysql死锁只能打印最后引起锁等待的2条语句,其实一共执行了4条语句,有办法能显示全部的4条吗?

执行的4条语句顺序如下:

1--update t_wait set name='bb' where id=2

2--update t_wait set name='cc' where id=3


3--update t_wait set name='cc1' where id=3

4---update t_wait set name='bb1' where id=2

只打印了3,4,1,2如何能显示出来呢?

show engine innodb status 的结果如下:

TRANSACTION 9693, ACTIVE 91 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1
MySQL thread id 13, OS thread handle 139724571465472, query id 9588 localhost root updating
update t_wait set name='cc1' where id=3
2023-08-31T09:30:00.561947Z 12 [Note] InnoDB: *** (1) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 44 page no 3 n bits 80 index PRIMARY of table `test_lock`.`t_wait` trx id 9693 lock_mode X locks rec but not gap waiting
Record lock, heap no 11 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 4; hex 80000003; asc ;;
1: len 6; hex 0000000025de; asc % ;;
2: len 7; hex 290000013b0abb; asc ) ; ;;
3: len 2; hex 6363; asc cc;;

2023-08-31T09:30:00.562128Z 12 [Note] InnoDB: *** (2) TRANSACTION:

TRANSACTION 9694, ACTIVE 53 sec starting index read
mysql tables in use 1, locked 1
4 lock struct(s), heap size 1136, 3 row lock(s), undo log entries 1
MySQL thread id 12, OS thread handle 139724571731712, query id 9589 localhost root updating
update t_wait set name='bb1' where id=2
2023-08-31T09:30:00.562152Z 12 [Note] InnoDB: *** (2) HOLDS THE LOCK(S):

RECORD LOCKS space id 44 page no 3 n bits 80 index PRIMARY of table `test_lock`.`t_wait` trx id 9694 lock_mode X locks rec but not gap
Record lock, heap no 11 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 4; hex 80000003; asc ;;
1: len 6; hex 0000000025de; asc % ;;
2: len 7; hex 290000013b0abb; asc ) ; ;;
3: len 2; hex 6363; asc cc;;

2023-08-31T09:30:00.562222Z 12 [Note] InnoDB: *** (2) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 44 page no 3 n bits 80 index PRIMARY of table `test_lock`.`t_wait` trx id 9694 lock_mode X locks rec but not gap waiting
Record lock, heap no 10 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 4; hex 80000002; asc ;;
1: len 6; hex 0000000025dd; asc % ;;
2: len 7; hex 28000001490a6d; asc ( I m;;
3: len 2; hex 6262; asc bb;;

2023-08-31T09:30:00.562294Z 12 [Note] InnoDB: *** WE ROLL BACK TRANSACTION (1)

我来答
添加附件
收藏
分享
问题补充
1条回答
默认
最新
chengang

https://www.modb.pro/db/627671

请看这个贴子。可以复原死锁的两个事务的所有SQL语句。

暂无图片 评论
暂无图片 有用 2
打赏 0
手机用户9375
2023-09-04
如果是5.7版本没有,statement_id ,需要如何修改呢?
回答交流
Markdown


请输入正文
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏