Open diogoceribelli opened 3 years ago
Magento is actually rife with possible race conditions.. The only place it uses real locking (SELECT ... FOR UPDATE
) is around the inventory. Everything else is anything goes. It may be possible to reorganize the code so that coupon loading and updates happen inside the transaction after the inventory is locked which would probably fix the issue. I personally am not in a position to tackle this myself right now, though.
I can confirm @colinmollenhour that real locking is SELECT ... FOR UPDATE
, an example:
I had used similar method above in a custom module to resolve a race condition.
I hope this comment is useful for tackling this issue.
[edit] I think this is the code @colinmollenhour is referring:
@kiatng But how to implement this in the shopping cart rule?
Magento 1.9
Steps to reproduce (*)
Expected result (*)
Actual result (*)
The problem then is that purchases made simultaneously will disregard the limit defined in the discount coupon rule. This should not happen, only one of those purchases should receive the discount.