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

Adjustments - Use explicit Row level deleted when computing taxes #38

Open
wants to merge 1 commit into
base: 2-2-stable-healthwave
Choose a base branch
from

Conversation

glongman
Copy link

@glongman glongman commented Apr 24, 2018

Tax computation occurs repeatedly per order, per line item, per step during checkout.
Spree::TaxRate computes new Adjustments after deleting the old ones.

A PR in Solidus pointed out that using delete_all can result in generated SQL that
contains polymorphic columns and caused INNODB to take gap locks. Under load this can result
in deadlock.

Using destroy_all means only primary key based deletes will occur. No gap locks so deadlocks can be
less likely.

spree_adjustments is a high traffic table. Spree::Adjustment has no after_destroy or relations that would invoke logic on destroy so this should be safe.

Ref: solidusio/solidus#127

Tax computation occurs repeatedly per order, per line item, per step during checkout.
Spree::TaxRate computes new Adjustments after deleting the old ones.

A PR in Solidus pointed out that using `delete_all` can result in generated SQL that
contains polymorphic columns and caused INNODB to take gap locks. Under load this can result
in deadlock.

Using `deleted_all` means only primary key based deleted will occur. No gap locks so deadlocks can be
less likely.

spree_adjustments is a high traffic table. Spree::Adjustment has no `after_destroy` or relations that would invoke logic on destroy so this should be safe.

Ref: solidusio/solidus#127
@lemuelbarango
Copy link

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants