If you use a transactional storage engine in MySQL like InnoDB some of your transaction may be terminated by the storage engine because of deadlocks. Sadly it is a bit tricky to see what has led to the deadlock. SHOW ENGINE INNODB STATUS gives only a very minimal look into the state when it happened.
With the proxy and a little script we can track what happened in all open transactions before the deadlock happened. A classic example is the cross-over deadlock:
[36] received a ERR(1213, Deadlock found when trying to get lock; try restarting transaction), dumping all active transactions
[35].1: select * from commit where id = 1 for update
[35].2: select * from commit where id = 2 for update
[36].1: select * from commit where id = 2 for update
[36].2: select * from commit where id = 1 for update
35 and 36 are the two transactions we have open, the last statement in 36 triggered the deadlock.
In the …
[Read more]