Hi @batmike. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
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?
@magento-engcom-team give me 2.3.1 instance
Hi @batmike. Thank you for your request. I'm working on Magento 2.3.1 instance for you
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.
@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.
@batmike this is just a bot :) Simply wow, thanks for such a fruitful investigation.
@kandy you should like this.
@orlangur - of course it is! Just trying to get used to talking more with the machines than people ahead of time.
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.
@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
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
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: :point_down:
Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.[x] 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.
[x] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[x] 4. Verify that the issue is reproducible on 2.3-develop
branchDetails
- 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_!
[x] 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
@batmike, @royandre, @acampos1916 do you have Magento Inventory (MSI) enabled in your Magento installation?
@andimov - we do not have any of the MSI modules enabled in our install.
@andimov we do have MSI enabled.
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 https://github.com/magento/magento2/issues/23077 and https://github.com/magento/magento2/pull/23294
@batmike, @acampos1916, thank you for your answers.
There are several reasons why price indexation takes a long time for large data profiles:
$select->where('type_id = ?', $typeId);
@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?
@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 https://github.com/magento/inventory/pull/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:
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 https://github.com/magento/inventory/pull/2336 it was completed in 5 hours.
@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.
@batmike your issue (without msi enabled) could be related to https://github.com/magento/magento2/pull/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.
@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.
@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.
@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.
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.
@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.
Thanks all, PR with changes were delivered
The issue covered by Performance Acceptance Test which required for each PR.
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!
Most helpful comment
@batmike, @acampos1916, thank you for your answers.
There are several reasons why price indexation takes a long time for large data profiles:
$select->where('type_id = ?', $typeId);
fixed that issue. This fix will be delivered to 2.3-develop soon with the tests coverage.