Open
Description
Preconditions and environment
- Magento version
Checked in 2.4.3 and 2.4.6 versions, reproducible in both - Anything else that would help a developer reproduce the bug
Have around 20k Simple products
Steps to reproduce
Step 1: Fetch Products in batches (using limit and offset)
Step 2: Iterate over the products
Step 3: Fetch SalableQty using GetProductSalableQtyInterface
Step 4: Record the peak memory usage using memory_get_peak_usage(). Observe that the peak memory usage increases slowly after every batch.
Comment out the calls to GetProductSalableQtyInterface and repeat steps 1-4. Observe that the peak memory usage remains the same.
Expected result
Peak Memory used should not increase consistently and should stabilize after few batches.
Actual result
Peak memory increases slowly and ultimately it goes OOM.
Additional information
Example Code
// $productCollectionFactory -> CollectionFactory
// $stockByWebsiteIdResolver -> StockByWebsiteIdResolverInterface
// $getProductSalableQtyInterface -> GetProductSalableQtyInterface
public function processInventory()
{
$collection = $this->productCollectionFactory->create();
$collection->addAttributeToSelect('*')
->addAttributeToFilter('type_id', ProductType::TYPE_SIMPLE)
->addStoreFilter($storeId)
->setStoreId($storeId);
$offset = 0;
$limit = 200;
do {
$products = $collection
->getSelect()
->order(new \Zend_Db_Expr('e.updated_at desc'))
->limit($limit, $offset);
$offset += $limit;
if (empty($products)) {
break;
}
foreach ($products as $product) {
$websiteId = (int)$product->getStore()->getWebsiteId();
$stockId = $this->stockByWebsiteIdResolver->execute($websiteId)->getStockId();
$qty = $this->getProductSalableQtyInterface->execute(
$product->getSku(),
$stockId
);
}
gc_collect_cycles();
echo "Peak Mem ". memory_get_peak_usage() ;
} while (true);
}
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmedMay be fixed according to the position in the backlog.Indicates original Magento version for the Issue report.The issue has been reproduced on latest 2.4-develop branchIssue related to Developer Experience and needs help with Triage to Confirm or Reject it