Deadlock found when trying to get lock

[已解决]MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction.

解决办法

1、查看INNODB状态,从日志中分析相互竞争的两个事务。

SHOW ENGINE INNODB STATUS;

2、Mysql InnoDB默认锁超时间为50s,一旦等待锁超时事务抛出异常而退出,死锁竞争也就消失了。

3、直接kill掉死锁事务。参考MySQL清理死锁线程