magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.47k stars 9.29k forks source link

Partial re-index should save its current state every so often #37368

Open hostep opened 1 year ago

hostep commented 1 year ago

Summary

When you have a huge backlog of items to be reindexed, it's not clear that something is actually happening and that the situation is slowly improving.

Examples

Check the indexer status and see something like this:

$ bin/magento indexer:status
+----------------------------------+-------------------------------------+--------+-----------+----------------------------+---------------------+
| ID                               | Title                               | Status | Update On | Schedule Status            | Schedule Updated    |
+----------------------------------+-------------------------------------+--------+-----------+----------------------------+---------------------+
| catalogrule_product              | Catalog Product Rule                | Ready  | Schedule  | idle (55690 in backlog)    | 2023-04-13 02:13:24 |
| catalogrule_rule                 | Catalog Rule Product                | Ready  | Schedule  | idle (0 in backlog)        | 2023-04-13 11:49:16 |
| catalogsearch_fulltext           | Catalog Search                      | Ready  | Schedule  | idle (128801 in backlog)   | 2023-04-13 02:14:23 |
| catalog_category_product         | Category Products                   | Ready  | Schedule  | idle (0 in backlog)        | 2023-04-13 11:47:39 |
| customer_grid                    | Customer Grid                       | Ready  | Schedule  | idle (0 in backlog)        | 2023-04-13 11:47:39 |
| design_config_grid               | Design Config Grid                  | Ready  | Schedule  | idle (0 in backlog)        | 2023-04-13 12:26:43 |
| catalog_product_category         | Product Categories                  | Ready  | Schedule  | idle (0 in backlog)        | 2023-04-13 11:49:16 |
| catalog_product_attribute        | Product EAV                         | Ready  | Schedule  | working (48384 in backlog) | 2023-04-13 11:49:16 |
| catalog_product_price            | Product Price                       | Ready  | Schedule  | idle (128801 in backlog)   | 2023-04-13 02:13:24 |
| cataloginventory_stock           | Stock                               | Ready  | Schedule  | idle (128801 in backlog)   | 2023-04-13 02:13:06 |
+----------------------------------+-------------------------------------+--------+-----------+----------------------------+---------------------+

Check again after an hour, and see that nothing has changed

I would like to see the number of backlogged items dropping, but that doesn't happen.

After many hours, the backlog will be back at zero, but some kind of progress indicator wouldn't be bad to try to estimate when the indexer would be finished.

Proposed solution

At regular intervals, try to store the current status of the indexers backlog, so we have some idea of if the indexer is actually doing something and how much items are still left to do

Has already been suggested a while ago: https://github.com/magento/devdocs/pull/8517#issuecomment-885465288 (last paragraph)

A custom module already does something similar: https://github.com/ho-nl/magento2-ReachDigital_BetterIndexer/blob/8c702588e89f047f2ec6628624868b625c324533/src/Plugin/ViewPlugin.php#L167-L169 (was suggested in https://github.com/magento/magento2/issues/30012#issuecomment-1499071484)

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @hostep. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

irajneeshgupta commented 1 year ago

Same case happening in our production after 246 upgrade. The progress of partial reindex completed but backlog items never updates untill i ran full reindex. Note that our production have over 100K items. @hostep did you find any workaround? @engcom-Bravo can you please check and confirm this issue.

hostep commented 1 year ago

@irajneeshgupta: Not yet no.

But I heard from @sidolov on Slack that the slow partial reindexing could get solved by quality patch ACSD-51114, which is not a solution to this issue, but to https://github.com/magento/magento2/issues/30012, however it strongly related though.

I haven't tried out the quality patch yet, however I've tried out https://github.com/magento/magento2/pull/36155 which should solve the same issue, and that one significantly speeds up partial reindexing + indexes the correct things. However, I've also noticed that the partial reindex of catalog_product_attribute is still pretty slow with that PR, it's a lot better then before, but still with a big catalog (~ 100K products) - in amounts of hours - very slow. Maybe the quality patch handles this indexer better, but I haven't found the time to test this out...

Not sure if this helps in your case, but feel free to try out the quality patch and report back (maybe best on https://github.com/magento/magento2/issues/30012 as that one is more related to the quality patch than this issue here).

irajneeshgupta commented 1 year ago

@hostep let me try that quality patch and observer partial indexer.

m2-assistant[bot] commented 1 year ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 1 year ago

Hello @hostep,

Thanks for the report and collaboration!

It seems that we can mark this issue as a feature request. Please suggest.

Thanks

hostep commented 1 year ago

@engcom-Hotel: sure, you can mark it as a feature request.

m2-assistant[bot] commented 1 year ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down: