views:

1457

answers:

3

Hi,

I know that deadlocks occur inevitably when using transactions in Innodb and that they are harmless if they are treated properly by the application code - "just try it again", as the manual says.

So I was wondering - how do you detect deadlocks? Does a deadlock issue some special mysql error number? I am using PHP's mysqli extension if that matters.

Thank you.

Edit: solution found, see comments

A: 

Try MaatKit. It has a deadlock logger.

jonstjohn
+1  A: 

http://dev.mysql.com/doc/refman/5.0/en/innodb-error-codes.html

1213 (ER_LOCK_DEADLOCK)

Transaction deadlock. You should rerun the transaction.

S.Lott
Thank you! That's what I was looking for.
raquo
Did you use Google? That's what I used.
S.Lott
A: 

Try innotop, will detect the deadlock for you.