-
Notifications
You must be signed in to change notification settings - Fork 253
Description
Race condition between orders
To prevent a race condition between orders. Which could happen in a next case:
The "Salable Quantity" on "Custom Stock" is 10 for SKU-1. "Custom Stock" consists of three sources:
- Source A, which contains 5 items of SKU-1
- Source B, which contains 4 items of SKU-1
- Source C, which contains 1 item of SKU-1
Altogether it gives us 5 + 4 + 1 = 10
Now there are 2 Customers coming to the site to place orders:
- Customer 1 orders 2 items of SKU-1 and choose a general delivery method (NOT Store Pickup)
- Customer 2 orders 4 items of SKU-1 and choose as a delivery method Store Pickup
With current behaviour of Source Selection Algorithm it could happen that if Customer's 1 order would be processed first, the SSA may suggest to make Source deduction from "Source A" which will lead to insufficient Quantity of SKU-1 (5 - 2 < 4) to fulfill the order placed by Customer 2.
To prevent this situation it's proposed to apply a rule that Store Pickup orders have higher priority than others, and SSA should work not with Source Availability Quantity, but with Source Availability Quantity minus all store pickup ordered quantities. In the case above it means that SSA for Customer 1 order should take Order placed by Customer 2 into account even so Order 2 was placed later, and the inbound data for SSA would be:
Source A: 5 - 4 = 1(subtract all store pickup items for this Source)- Source B: 4
- Source C: 1