mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Deal with increment parallelism #7052
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @l-you on GitHub (Sep 29, 2022).
Suppose we have e-commerce website with hot sales. There often can be a case where product stock is decremented in parallel requests.
Solution can be to use mysql directly
UPDATE product SET stock=stock-1.But it has drawbacks. For example task is "Create order and reduce stock". I reduce stock with direct mysql query, but during
->flush()exception appears and order not saved. So I have reduced stock and no order.Is there a way
UPDATE product SET stock=stock-1to be persisted, so it will execute with other updates when->flush()is called?