Prevent, handle deadlocks

from the Artful MySQL Tips List

1. The shorter the transaction, the less likely is a deadlock.

2. Use snapshot isolation,

3. A deadlock when multiple transactions try to lock the same keys in differing orders. To prevent that, ensure that keys are locked in the same order.

4. Avoid user interaction in transaction sequences.

5. In a busy system, deadlocks are not completely preventable, so transaction code [i]must[/i] include retry capability.

Last updated 16 Aug 2019

Return to the Artful MySQL Tips page