记录一下: 原因:spring事务提交时导致数据库事务得不到释放,产生死锁问题,紧接着抛出操作超时异常:MySQLTransactionRollbackException: Lock wait timeout exceeded; try
原因:spring事务提交时导致数据库事务得不到释放,产生死锁问题,紧接着抛出操作超时异常:MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
有可能是因为spring的事务嵌套引起的问题,总之先解决眼前的问题,把Mysql中产生死锁的事务进程干掉,所以记录一下sql
相关sql记录:
-- 查看数据库当前的进程show processlist;-- 当前运行的所有事务SELECT * FROM infORMation_schema.INNODB_LOCKs;-- 当前出现的锁SELECT * FROM information_schema.INNODB_LOCK_waits;-- 锁等待的对应关系SELECT * FROM information_schema.INNODB_TRX;-- 查询产生锁的具体sqlselect a.trx_id 事务id , a.trx_mysql_thread_id 事务线程id, a.trx_query 事务sql from INFORMATION_SCHEMA.INNODB_LOCKS b, INFORMATION_SCHEMA.innodb_trx a where b.lock_trx_id=a.trx_id;-- !!!select concat('KILL ',a.trx_mysql_thread_id ,';') from INFORMATION_SCHEMA.INNODB_LOCKS b,INFORMATION_SCHEMA.innodb_trx a where b.lock_trx_id=a.trx_id;-- 杀掉死锁进程kill {thread_id};
在事务回滚注解中添加参数:propagation = Propagation.REQUIRES_NEW(默认为:Propagation.REQUIRED)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) ResponseData updateBath(List entity) throws ParseException;
--结束END--
本文标题: mysql数据库死锁问题解决MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transact
本文链接: https://www.lsjlt.com/news/372129.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0