Skip to content

Question and possibly bug: Delete and then insert in inventory_stock_{$id} might be causing out of stock issue #3443

@adarshkhatri

Description

@adarshkhatri

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:

$this->indexStructureHandler->cleanIndex(
$indexName,
new ArrayIterator($composableSkus),
$connectionName
);
$this->indexStructureHandler->saveIndex($indexName, new ArrayIterator($data), $connectionName);

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.

Metadata

Metadata

Assignees

Labels

Issue: needs updateTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions