Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a condition which would lead to MySQL deadlock
Running a delete by an index condition, for example: ``` DELETE FROM spree_adjustments WHERE adjustable_id = 1 AND adjustable_type = 'Spree::Shipment' ``` will require MySQL to acquire a gap lock on the index which indexes adjustable_id and adjustable_type. Running this in a heavily loaded environment can lead to deadlocks in MySQL as multiple threads need an exclusive gap lock on the index in question. By deleting records by the primary key instead, MySQL is able to deal with this without requiring an exclusive lock on the primary key index, avoiding the deadlock situation.
- Loading branch information