Lock wait timeout exceeded; try restarting transaction解决方案

时间:2024-04-07 10:20:33

在测试程序时,打的断点怎么都跳不进去,console一直报 “Lock wait timeout exceeded; try restarting transaction”

org.springframework.dao.CannotAcquireLockException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.LockAcquisitionException: could not execute statement。

 

 

从字面意思得知,是表锁了所以进不到断点里面,查看代码发现:

Lock wait timeout exceeded; try restarting transaction解决方案

此处是在对list做更新动作,因此存在锁表的风险。

Mysql 查看锁:


select * from information_schema.innodb_trx ## 当前运行的所有事务

select * from information_schema.innodb_locks ##当前出现的锁 

select * from information_schema.innodb_lock_waits ## 锁等待的对应关系。

把对应的trx_id kill掉即可。

Lock wait timeout exceeded; try restarting transaction解决方案