Question and possibly bug: Delete and then insert in inventory_stock_{$id} might be causing out of stock issue
- Dominant language
- PHP
- Stars
- 357
- Forks
- 262
- PR merge metrics
- No merged PRs in 30d
Description
From time to time, the highest-selling product goes out of stock, even though there is plenty of stock still available and on top it is also set as Back order YES.
**There is this code:**
https://github.com/magento/inventory/blob/adfc40b34f3de880f2b10861b84ec3cd69c3bd4b/InventoryIndexer/Indexer/Stock/IndexDataFiller.php#L70-L75
As you can see system is deleting the rows first and then inserting a new one.
We think that when it deletes rows, and before it has inserted a new one, there is another processor that is trying to set salability: `bin/magento queue:consumers:start inventory.reservations.updateSalabilityStatus`, which will set the product to out of stock as it cannot find the row in the inventory stock table.
**Why do we need to delete the row? There is `insertOnDuplicate` anyway.**
### Preconditions (*)
1. 2.4.6 Commerce
### Steps to reproduce (*)
Hard to reproduce, we were able to reproduce only once in our dev env, and it keeps happening in prod.
### Expected result (*)
1. Product is always in-stock
### Actual result (*)
1. Time to time product is out of stock.
Contributor guide
Assessment
This issue has not been assessed yet.