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

Deadlock occuring randomly #69

Closed
Codeweld opened this issue Feb 8, 2020 · 5 comments
Closed

Deadlock occuring randomly #69

Codeweld opened this issue Feb 8, 2020 · 5 comments

Comments

@Codeweld
Copy link
Contributor

Codeweld commented Feb 8, 2020

Current behavior

It happens that deadlock occurs during standard operations in VSF. It is related to Timestampable which is trying to modify updated_at of currently processed object.

update

Expected behavior

Deadlocks should not happen.

Steps to reproduce the issue

It occurs during standard operations in VSF, just:

  • login to your account
  • modify content of your cart
  • ...deadlock should be found eventually

Suggested steps to fix the issue

  • give up on doctrine_transaction middleware in messenger
  • custom middleware for doctrine transactions implementing retries in case of a deadlock
@Codeweld Codeweld mentioned this issue Apr 13, 2020
@dperkosan
Copy link

dperkosan commented Apr 14, 2020

I found query that is causing deadlock, but do you know why is sylius_order table updated on VSF refresh? I couldn't find which API end point is doing that. I run one by one end point in postman and sylius_order table was not updated. Only on VSF refresh...

deadlock

@dperkosan
Copy link

btw, I removed - doctrine_transaction from middleware and problem still exists.

@Codeweld
Copy link
Contributor Author

Thank you for sharing what you've discovered.
We will look into that soon, it's a critical issue and has to be resolved.

@diimpp
Copy link

diimpp commented Nov 30, 2020

That's a typical issue with sylius in asyc environments. Each api request, that triggers order_processing can be executed in parallel for the same order, which will result in deadlocks, weird price adjustments, inconsistent totals. (This probably related as well #68)

Reason is that order consist of several tables and doctrine transaction is not longer enough to ensure data consistency.

Solution is to wrap whole order_processing in business transaction, for example with pessimistic lock via symfony/lock
Something like LockingOrderProcessor, which will decorate CompositeOrderProcessor with appropriate priority should do the trick.

More on the topic
Sylius/ShopApiPlugin#667

@PiotrSzymanski2000
Copy link

The current solution is deprecated as it was created for Vue Storefront v1. For Vue Storefront 2 integration check out our GraphQL-based integration - https://github.com/BitBagCommerce/SyliusVueStorefront2Plugin

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

No branches or pull requests

4 participants