com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
时间: 2023-08-15 10:14:53 浏览: 187
mysql报错:Deadlock found when trying to get lock; try restarting transaction的解决方法
回答: 引发com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction异常的原因是发生了死锁。死锁是指两个或多个线程互相持有对方需要的资源,导致它们都无法继续执行。在这种情况下,MySQL会自动选择一个事务进行回滚,以解除死锁。\[3\]死锁的产生原因有很多,比如多线程、线程池、多条SQL操作同一张表等。为了避免死锁的发生,可以使用jemet性能测试对容易产生死锁的接口进行测试。另外,您可以通过查看MySQL的事务和锁的情况来进一步了解死锁的具体情况,可以使用以下命令来查看:show processlist; select * from information_schema.innodb_trx; SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS; SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS; \[2\]
#### 引用[.reference_title]
- *1* [mybatis使用foreach批量insert异常的解决办法(复杂嵌套sql不支持)](https://blog.csdn.net/y666666y/article/details/106651906)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException:](https://blog.csdn.net/weixin_43206161/article/details/126732919)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文