项目中开启事务,批量执行update语句时,在debug调试的时候中途停掉了服务,产生了没有提交的事务,导致再次执行update时出现超时并报错Lock wait timeout exceeded; try restarting transaction。
MYSQL出现死锁,首先查询information_schema.innodb_trx表,打开mysql命令行,查看哪些mysql查询线程ID导致的:
mysql>
select * from information_schema.innodb_trx \G;
查出对应死锁记录,查到线程id(trx_mysql_thread_id),再通过 kill 线程id 即可。