`

Avoid MySQL [Deadlock found when trying to get lock; try restarting transaction]

阅读更多

        偶尔一天,监控到程序异常:  OperationalError: (1213, 'Deadlock found when trying to get lock; try restarting transaction').

       通过网络Seach,发现show innodb status (MySQL5.1以下可以用)/show engine innodb status(MySQL5.1以上可用) 查看  the LATEST DETECTED DEADLOCK

可以具体看到是哪两个SQL引起的死锁. 但需注意的是后面一个DEAD LOCK Info会覆盖之前的,所以需要监控才能发现问题所在.

 

     进一步通过Search,发现是有方案可以避免它,参考:

http://stackoverflow.com/questions/2332768/how-to-avoid-mysql-deadlock-found-when-trying-to-get-lock-try-restarting-trans

 

    

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics