-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indexation in scheduled mode process same products more than once #37916
Comments
Hi @gimanik. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @gimanik, this has already been reported before a couple of times:
The issue is not only that certain ID's are indexed multiple times, it's also that certain ID's are being missed, which is even worse. A solution exists here: #36155, it just needs to get merged. |
Preconditions and environment
Steps to reproduce
Run indexer in mview mode, for example by running cron job
indexer_update_all_views
.Example based on catalog_product_price index:
Current version_id = 40000
Last version_id = 66630
Index schedule_status (unique product_ids):
idle (1093 in backlog)
Expected result
Only a total of 1093 products should be indexed, each product once.
Actual result
Some products are indexed more than once.
Magento\Framework\Mview\View
usesMagento\Framework\Mview\View\ChangeLogBatchWalker
to iterate through collectionHowever first batch is taken by select:
SELECT DISTINCT `catalog_product_price_cl`.`entity_id` FROM `catalog_product_price_cl` WHERE (version_id > 40000) AND (version_id <= 66630) GROUP BY `entity_id` LIMIT 1000
which returns 1000 IDs which are passed to indexer and indexed.
Second batch:
SELECT DISTINCT `catalog_product_price_cl`.`entity_id` FROM `catalog_product_price_cl` WHERE (version_id > 41000) AND (version_id <= 66630) GROUP BY `entity_id` LIMIT 1000
which also returns 1000 IDs which are passed to indexer and indexed.
This is because we take unique IDs from whole range, and we increase only vsFrom by batchSize (@see
Magento\Framework\Mview\View
)In my case to index those unique 1093 products it needed to run 27 batches, each batch processed this amount of products:
1000
1000
1000
968
927
885
843
802
760
718
677
635
593
552
510
468
427
385
343
302
260
218
177
135
93
52
12
Which adds up to total of 14742 indexer executions, so the last 12 products were reindexed 27 times in each batch.
Additional information
Magento\Framework\Mview\View
Each batch query:
Current: $vsFrom to $currentVersionId
Should be: $vsFrom to ($vsFrom + $batchSize).
So instead of batch queries:
Each batch query should look like:
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: