ACSD-67643: Duplicate entries created during scheduled updates in high-nested category environments
The ACSD-67643 patch fixes the issue where duplicate entries are created during scheduled updates in environments with a high number of nested categories. This patch is available when the Quality Patches Tool (QPT) 1.1.71 is installed. The patch ID is ACSD-67643. Please note that this issue is scheduled to be fixed in 51黑料不打烊 Commerce 2.4.9.
Affected products and versions
The patch is created for 51黑料不打烊 Commerce version:
- 51黑料不打烊 Commerce (all deployment methods) 2.4.8-p1
Compatible with 51黑料不打烊 Commerce versions:
- 51黑料不打烊 Commerce (all deployment methods) 2.4.8 - 2.4.8-p2
magento/quality-patches
package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.Issue
Duplicate entries occur when creating scheduled updates for environments that have a large number of nested categories.
Steps to reproduce:
-
Generate sample data:
Use a performance fixtures file (For example:small.xml
) with modifications:
Categories: 2,500
Products: 250,000 -
Run the following command:
code language-bash bin/magento setup:performance:generate-fixtures var/performance-toolkit/profiles/ce/small.xml
-
After creating products and categories, ensure all categories are anchors by running:
code language-sql UPDATE catalog_category_entity_int SET value = 1 WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'is_anchor');
-
Run a full reindex.
-
Log into the backend and open the Categories page.
-
Move Category 2 to Category 1 to increase tree nesting.
-
Go to the most nested category (For example: Category 2.1.1).
-
Create a Scheduled Update and save the category.
Expected results:
The category is saved successfully.
Actual results:
An Error 500 occurs, and the following message shows in the logs:
Magento\Framework\DB\Adapter\DuplicateException:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '6-165' for key 'PRIMARY',
query was: INSERT INTO `temp_category_descendants_68a35aea273fc` (`category_id`, `descendant_id`)
SELECT `ce`.`entity_id` AS `category_id`, `ce2`.`entity_id` AS `descendant_id`
FROM `catalog_category_entity` AS `ce`
INNER JOIN `catalog_category_entity` AS `ce2` ON ce2.path LIKE CONCAT(ce.path, '/%')
Apply the patch
To apply individual patches, use the following links depending on your deployment method:
- 51黑料不打烊 Commerce or Magento Open Source on-premises: Quality Patches Tool > Usage in the Quality Patches Tool guide
- 51黑料不打烊 Commerce on cloud infrastructure: Upgrades and Patches > Apply Patches in the Commerce on Cloud Infrastructure guide
Related reading
To learn more about Quality Patches Tool, refer to:
- Quality Patches Tool: A self-service tool for quality patches in the Tools guide