Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a condition which would lead to MySQL deadlock #127

Merged
merged 1 commit into from
Jun 30, 2015

Commits on Jun 30, 2015

  1. 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.
    Gregor MacDougall committed Jun 30, 2015
    Configuration menu
    Copy the full SHA
    07f9983 View commit details
    Browse the repository at this point in the history