mysql> show innodb status /G ……. ------------------------ LATEST DETECTED DEADLOCK ------------------------ 070710 14:05:16 *** (1) TRANSACTION: TRANSACTION 0 117470078, ACTIVE 117 sec, process no 1468, OS thread id 1197328736 inserting mysql tables in use 1, locked 1 LOCK WAIT 5 lock struct(s), heap size 1216 MySQL thread id 7521657, query id 673468054 localhost root update insert into country (country_id,country) values(110,'Test') ………
*** (2) TRANSACTION: TRANSACTION 0 117470079, ACTIVE 39 sec, process no 1468, OS thread id 1164048736 starting index read, thread declared inside InnoDB 500 mysql tables in use 1, locked 1 4 lock struct(s), heap size 1216, undo log entries 1 MySQL thread id 7521664, query id 673468058 localhost root statistics select first_name,last_name from actor where actor_id = 1 for update *** (2) HOLDS THE LOCK(S): ………
如果出现死锁,可以用SHOW INNODB STATUS命令来确定最后一个死锁产生的原因。返回结果中包括死锁相关事务的详细信息,如引发死锁的SQL语句,事务已经获得的锁,正在等待什么锁,以及被回滚的事务等。据此可以分析死锁产生的原因和改进措施。下面是一段SHOW INNODB STATUS输出的样例:mysql> show innodb status /G…….------