mysql出现Deadlock死锁排查

参考: https://www.yisu.com/zixun/664543.html

查看mysql死锁日志

show engine innodb status

找到信息中LATEST DETECTED DEADLOCK这一行,可以看到mysql的死锁信息详情

------------------------
LATEST DETECTED DEADLOCK
------------------------
2023-10-31 10:39:46 0x454c
*** (1) TRANSACTION:
TRANSACTION 92835125, ACTIVE 7 sec fetching rows
mysql tables in use 1, locked 1
LOCK WAIT 183 lock struct(s), heap size 24784, 21601 row lock(s), undo log entries 1
MySQL thread id 607, OS thread handle 13228, query id 748731 USER-20201018QG 192.168.4.57 root updating
UPDATE battle_confrontation_zone  SET result=0,
score=0,


is_exit_midway='1',



update_by='',
update_time='2023-10-31 10:41:30.259'  
 
 WHERE (room_id = '1698720784400' AND user_id = 533)
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 50870 page no 263 n bits 232 index PRIMARY of table `medical-insurance-city-test`.`battle_confrontation_zone` trx id 92835125 lock_mode X waiting
Record lock, heap no 162 PHYSICAL RECORD: n_fields 15; compact format; info bits 0

处理

对update的where条件添加复合索引
在这里插入图片描述

你可能感兴趣的:(mysql,数据库)