死锁是指两个或两个以上的进程在执行过程中,因争夺资源而造成的一种互相等待的现象,可以认为如果一个资源被锁定,它总会在以后某个时间被释放。而死锁发生在当多个进程访问同一数据库时,其中每个进程拥有的锁都是其他进程所需的,由此造成每个进程都无法继续下去。 InnoDB的并发写操作会触发死锁,InnoDB也提供了死锁检测机制,可以通过设置innodb_deadlock_detect参数可以打开或关闭死锁检测: 还可以通过设置InnDB Monitors来进一步观察锁冲突详细信息 设置InnoDB Monitors方法 建立test库 mysql>create database test; Query OK, 1 row affected (0.20 sec) mysql> use test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A 可以通过show engine innodb status命令查看死锁信息 mysql> show engine innodb status /G *************************** 1. row *************************** Type: InnoDB Name: Status: ===================================== 2018-05-10 09:17:10 0x7f1fbc21a700 INNODB MONITOR OUTPUT ===================================== Per second averages calculated from the last 46 seconds ----------------- BACKGROUND THREAD ----------------- srv_master_thread loops: 53 srv_active, 0 srv_shutdown, 240099 srv_idle srv_master_thread log flush and writes: 0 ---------- SEMAPHORES ---------- OS WAIT ARRAY INFO: reservation count 2007 OS WAIT ARRAY INFO: signal count 1987 RW-shared spins 3878, rounds 5594, OS waits 1735 RW-excl spins 3, rounds 91, OS waits 4 RW-sx spins 1, rounds 30, OS waits 1 Spin rounds per wait: 1.44 RW-shared, 30.33 RW-excl, 30.00 RW-sx ------------ TRANSACTIONS ------------ Trx id counter 78405 Purge done for trx's n:o < 78404 undo n:o < 10 state: running but idle History list length 21 LIST OF TRANSACTIONS FOR EACH SESSION: ---TRANSACTION 421249967052640, not started 0 lock struct(s), heap size 1136, 0 row lock(s) -------- FILE I/O -------- I/O thread 0 state: waiting for completed aio requests (insert buffer thread) I/O thread 1 state: waiting for completed aio requests (log thread) I/O thread 2 state: waiting for completed aio requests (read thread) |
免责声明:本站部分文章和图片均来自用户投稿和网络收集,旨在传播知识,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系我们及时修正或删除。谢谢!
始终以前瞻性的眼光聚焦站长、创业、互联网等领域,为您提供最新最全的互联网资讯,帮助站长转型升级,为互联网创业者提供更加优质的创业信息和品牌营销服务,与站长一起进步!让互联网创业者不再孤独!
扫一扫,关注站长网微信