Skip to content
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

Pricing Index runs without ever completing - Magento 2.3.1 #22516

Closed
batmike opened this issue Apr 26, 2019 · 27 comments
Closed

Pricing Index runs without ever completing - Magento 2.3.1 #22516

batmike opened this issue Apr 26, 2019 · 27 comments
Assignees
Labels
Component: Indexer good first issue Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@batmike
Copy link

batmike commented Apr 26, 2019

Preconditions (*)

  1. Magento 2.3.1
  2. PHP 7.2
  3. MySQL 5.7

Steps to reproduce (*)

  1. Heavily configurable product based catalog - about 375,000 total products of which about 15,000 are configurable products and the remaining 350,000 are simple products links to the configurables.
  2. Upon upgrading to version 2.3.1 from version 2.3.0, the pricing index (catalog_product_price) would not complete indexing and would run without ending (in my environment, I let it run out to about 50 hours before giving up)
  3. After reverting the changes made in the following commits, pricing index was able to be rebuilt again:

Expected result (*)

  1. Pricing index should be able to be fully rebuilt and moved into the active price database table in a reasonable amount of time

Actual result (*)

  1. Pricing index does not rebuild after our maximum test time of 45 hours.
  2. With a 32 core, 120 GB RAM server, the pricing index was able to be rebuilt in approximately 3 minutes on the above catalog size configuration after the rollback of the noted commits to version 2.3.1.
@m2-assistant
Copy link

m2-assistant bot commented Apr 26, 2019

Hi @batmike. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@batmike do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Apr 26, 2019
@batmike
Copy link
Author

batmike commented Apr 26, 2019

@magento-engcom-team give me 2.3.1 instance

@magento-engcom-team
Copy link
Contributor

Hi @batmike. Thank you for your request. I'm working on Magento 2.3.1 instance for you

@magento-engcom-team
Copy link
Contributor

Hi @batmike, here is your Magento instance.
Admin access: https://i-22516-2-3-1.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@batmike
Copy link
Author

batmike commented Apr 26, 2019

@magento-engcom-team

I have the instance but cannot confirm as I would need to run some kind of sample data loader to build out a similar configurable/simple product catalog like we have in production. I also have to way to run the indexer from the CLI.

If these are available to run in a test vanilla environment, I'd be happy to test and see if it still does a similar thing to what we experienced.

@orlangur
Copy link
Contributor

orlangur commented Apr 26, 2019

@batmike this is just a bot :) Simply wow, thanks for such a fruitful investigation.

@kandy you should like this.

@batmike
Copy link
Author

batmike commented Apr 26, 2019

@orlangur - of course it is! Just trying to get used to talking more with the machines than people ahead of time.

@royandre
Copy link

royandre commented Jun 4, 2019

We are experiencing the same issue in 2.3.1 (multi-site, +80k SKUs (around 15k configurable, with simples attached), with the price index taking like forever (7+ hours), though we actually managed to finish it, and thus have the product appear in the store.

We are trying to tune the batch size (https://devdocs.magento.com/guides/v2.3/extension-dev-guide/indexer-batch.html), which seems to might affect this, so recommend others experiencing this issue to also check the batching as mentioned in the above link.

@acampos1916
Copy link

@royandre we're in a similar situation and get a very slow price reindexing. We adjusted the batch size for configurable and default down to 1000 and the improvement is not great. What batching setup did you end up using?

Investigating the catalog_product_index_price_temp temporal table I can see that it gets populated by a query that is exponentially slower as more products are enabled in more store views or at least that's what I think.

2.3.1 EE, 60k SKUs, 7k configurables

@enl
Copy link
Contributor

enl commented Jul 8, 2019

It looks like this guy ignores product's type when it creates batches and therefore each indexer walks through all the products: https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php#L275

@andimov andimov self-assigned this Jul 8, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jul 8, 2019

Hi @andimov. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.
    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

@andimov
Copy link
Contributor

andimov commented Jul 8, 2019

@batmike, @royandre, @acampos1916 do you have Magento Inventory (MSI) enabled in your Magento installation?

@batmike
Copy link
Author

batmike commented Jul 9, 2019

@andimov - we do not have any of the MSI modules enabled in our install.

@acampos1916
Copy link

@andimov we do have MSI enabled.

@alex-79
Copy link

alex-79 commented Jul 10, 2019

Trigger is not working correctly:

vendor/magento/framework/Mview/View/Subscription.php

Magento 2.2.5:

foreach ($columnNames as $columnName) {
    $columns[] = sprintf(
        'NEW.%1$s != OLD.%1$s',
        $this->connection->quoteIdentifier($columnName)
    );
}

Magento 2.3.1:

foreach ($columnNames as $columnName) {
    $columns[] = sprintf(
        'NEW.%1$s <=> OLD.%1$s',
        $this->connection->quoteIdentifier($columnName)
    );
}

!= is not <=>

See #23077 and #23294

@andimov andimov added the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Jul 10, 2019
@andimov
Copy link
Contributor

andimov commented Jul 12, 2019

@batmike, @acampos1916, thank you for your answers.

There are several reasons why price indexation takes a long time for large data profiles:

@batmike
Copy link
Author

batmike commented Jul 12, 2019

@andimov - I made the change to the getBatchesForIndexer() method but it didn't seem to improve the indexing time, with or without the batch modification. However, I enabled the MSI modules and then applied the PR 2336 and the rebuild now completes in just a couple minutes.

Is there any reason that the processing should still be degraded so much with MSI disabled though?

@andimov
Copy link
Contributor

andimov commented Jul 15, 2019

@batmike thank you for updates!
Yeah, it's weird. Please, try to disable MSI with patch and run indexation one more time to recheck degradation.
Fix from magento/inventory#2336 shouldn't affect your price indexation performance until you install MSI itself, but without MSI you should have at least the same indexation time as you receive with the fix.

I performed tests with data profile 10 times less as you described with fresh Magento Open Source installation from 2.3-develop and I received such results:

  • changes in getBatchesForIndexer give 10-12 times improvement
  • changes in batch-size ~10% improvement

I also performed tests with Magento Commerce along with MSI with a large profile (10m eSKU) and I wasn't able to receive successful indexation for 50+ hours. With hotfix similar to magento/inventory#2336 it was completed in 5 hours.

@batmike
Copy link
Author

batmike commented Jul 15, 2019

@andimov - Yes, you are right and your numbers look similar to what I'm seeing. When I let it run longer to test out the full benefit of the fix, the price indexing on our store completed in about 1.5 hours, which was much better than not finishing at all.

1.5 hours still isn't great compared to 5-6 minutes as we got prior in version 2.3.0 but ideally we would be able to use more of the incremental indexing rather than full reindexes which should reduce processing as well.

@seyuf
Copy link

seyuf commented Jul 22, 2019

@batmike your issue (without msi enabled) could be related to #23294. You should try the fix.
Also, to improve re-indexation time you can try multithread/multi-dimension feature available since 2.2.6 i believe (MAGE_INDEXER_THREADS_COUNT=3 php -f bin/magento indexer:reindex), it's working like a charm for me as a temp solution on a 300K+ catalog.

@batmike
Copy link
Author

batmike commented Jul 23, 2019

@seyuf - thanks for the ideas! I made the change in #23294 but it didn't result in much improvement. I've had it running in our staging environment and it's consistently reindexing pricing in about 50 minutes so the 1.5 hour mark I mentioned earlier wasn't exactly right.

I did also give the multi-threading a try but from looking into that, it seems that it would really only be helpful if we had multiple types of pricing - i.e. store views, customer types, and so on - and it would index those various breakouts in parallel. We have a simple setup though with just one store view and no pricing tiers or anything so there's unfortunately not much to parallel process.

@seyuf
Copy link

seyuf commented Jul 23, 2019

@batmike if you're sure you've correctly applied the fix...
Because, if i remember correctly, you have to at least make a setup upgrade to update the triggers in the db.

@batmike
Copy link
Author

batmike commented Jul 23, 2019

@seyuf - I didn't originally confirm that so I ran setup:upgrade and confirmed that the triggers are updated in the database with NOT NEW. They are correct now but the price reindexing for us is still taking 50 minutes. I'm not against blaming our environment or even the ratio we have of configurable to simple products, which is about 1 configurable for every 40 simple products on average but in reality it's probably a much wider range with many being 1:5 but a number of them much higher around 1:100 or so.

@seyuf
Copy link

seyuf commented Jul 23, 2019

Yeah, there should be no increase in full reindexing performance due to the fix. But it will allow you to avoid full reindexing in favor of incremental one. Also on 2.3.1, to avoid indexing issues i set the index cron group (from the BO admin section) Use Separate Process to no. To avoid conflicts during incremental indexing.

@batmike
Copy link
Author

batmike commented Jul 23, 2019

@seyuf - that sounds very good. I'll be testing that out and update here with the results. Thanks!

Update ... changing to the incremental updating could potentially work but we have a process that imports stock quantity updates from our inventory system and that's pretty much constant as we have physical stores that sell and transfrer items throughout the day so updated quantities are constantly coming into our site to be processed. With that, using the incremental indexing even just on pricing hangs up the database as each of those stock updates triggers some reindex processes that make it take much longer and drag the site down.

In the end, this has resulted in a good compromise as we've been able to enable incremental indexing on some of the indexes and then keep full indexing enabled for the bigger ones that take too long for the Magento crontab jobs to deal with. The fixes above noted by @andimov did definitely resolve the major issue with the index taking 10s or 100s of hours, which was my main thing.

@andimov
Copy link
Contributor

andimov commented Jul 26, 2019

Thanks all, PR with changes were delivered
The issue covered by Performance Acceptance Test which required for each PR.

@andimov
Copy link
Contributor

andimov commented Jul 30, 2019

The issue has been fixed in 2.3-develop branch
The fix will be available with the upcoming 2.3.3 release.
I have to close this issue.
Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Indexer good first issue Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

10 participants