在測試程序時,打的斷點怎麼都跳不進去,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。
從字面意思得知,是表鎖了所以進不到斷點裏面,查看代碼發現:
此處是在對list做更新動作,因此存在鎖表的風險。
Mysql 查看鎖:
select * from information_schema.innodb_trx ## 當前運行的所有事務
select * from information_schema.innodb_locks ##當前出現的鎖
select * from information_schema.innodb_lock_waits ## 鎖等待的對應關係。
把對應的trx_id kill掉即可。