Fixed: Deadlock When a MySQL Transaction Inserts a Child Row Before Updating the Parent
Two transactions touch only one product, and in the same order, and they still deadlock with ERROR 1213. The hidden lock comes from the foreign key: inserting a child row takes a shared lock on its parent. When both then try to update the parent, neither can go on. The fix is to swap two lines.
