MySQL Error Message
Deadlock found when trying to get lock; try restarting
transaction
Reason for the Error
InnoDB reports this error when a
transaction encounters a
deadlock and is automatically
rolled back so that your
application can take corrective action. To recover from this
error, run all the operations in this transaction again. A
deadlock occurs when requests for locks arrive in inconsistent
order between transactions. The transaction that was rolled back
released all its locks, and the other transaction can now get all
the locks it requested. Thus, when you re-run the transaction that
was rolled back, it might have to wait for other transactions to
complete, but typically the deadlock does not recur. If you
encounter frequent deadlocks, make the sequence of locking
operations (LOCK TABLES, SELECT …
FOR UPDATE, and so on) consistent between the different
transactions or applications that experience the issue. See
Deadlocks in InnoDB for details.