一个提示是,您可以使用SHOW INNODB STATUS来显示InnoDB引擎的状态.
它返回的信息(大块文本)包括有关当前表锁的信息,以及最后检测到的死锁(在标题为“ LATEST DETECTED DEADLOCK”下),因此,在此事实之后,此技巧并不是很有用,但是可以帮助您跟踪挂起的查询.
mysqladmin debug还可以打印有用的锁调试信息.
HTH!
更新:
因为它实际上不是死锁,所以它可能没有检测到死锁,但是更有可能一个进程正在等待另一进程锁定的行上的行锁.从手册中获取innodb_lock_wait_timeout变量:
The timeout in seconds an InnoDB
transaction may wait for a row lock
before giving up. The default value is
50 seconds. A transaction that tries
to access a row that is locked by
another InnoDB transaction will hang
for at most this many seconds before
issuing the following error:
ERROR 1205 (HY000): Lock wait timeout
exceeded; try restarting transaction
When a lock wait timeout occurs, the
current statement is not executed. The
current transaction is not rolled
back. (Until MySQL 5.0.13 InnoDB
rolled back the entire transaction if
a lock wait timeout happened.
例如,当两个进程各自需要锁定由另一个进程锁定的行时,就会发生死锁,并且没有任何等待量可以解决冲突.