
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)
