-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Remove Magento/Customer/Setup/RecurringData.php #21235
Remove Magento/Customer/Setup/RecurringData.php #21235
Conversation
Hi @slackerzz. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slackerzz I believe this file was added for a reason. Please find out why it was added in the first place and then we can decide whether it is still needed or not.
@orlangur i cannot know the reason why this was added, at first it seems a bad copy-paste. |
@slackerzz from dc4bb0e#diff-1868f52993762635208d45246e032b70 it looks like it was intentionally moved. Please analyze commit history to assure removal of this code won't cause any regression. |
Intentionally or unintentionally this means that a deploy will have about 10 minutes of maintenance. This is not acceptable for a real shop. |
@slackerzz we cannot remove code "just because". For a particular shop, where it causes troubles, it can be removed. However, if there is a real problem fixed by this recurring update, instead of just a removal a proper fix should be elaborated. |
Ok, don't worry. I'll prepare a composer patch. |
Hi @slackerzz, thank you for your contribution! |
Let's not close this just because of not agreeing with each other. @slackerzz has a valid point here. @orlangur also has a point. Maybe @sereban can shed some light on why this RecurringData script was added in the first place? |
@slackerzz Perhaps we need to add functionality where it will be necessary to do reindex only when it is needed? |
This probably won't help much with discovering why this was added, but here are all the commits which contain the phrase (maybe someone with access to Magento's Jira system can find more info in that particular ticket around this?)
|
@hostep I believe |
So if we track down where the reindex in the upgrade script was introduced, it looks like it was done over here: dc19322 Over here it was just called at the end of the |
Hi @hostep, chiming in a little bit here. I'm a lurker from #19469 and both an advocate of removing the recurring data script and finding out why it was put there in the first place to ensure it can safely be removed. I am slowly but surely working on migrating from M1 -> M2 with a site that has around 500k users and experiencing > 1hr times consistently from In regards to your question -- as stated in the Magento2 docs:
Would love to hear from @sereban as to why this is needed. And thank you @giacmir to inquiring within the commit. For anyone who might be affected by this, a possible workaround might be to declare a preference for a custom RecurringData script through a di.xml file. Simply leave the app/code/YourVendor/YourPackage/etc/di.xml
app/code/YourVendor/YourPackage/Setup/RecurringData.php
|
While waiting for an "official" answer from the author I'll try to guess on why that code is in there. In my opinion that reindex was added to ensure that if some setup, even from a module other than Magento_Customer changes something to the customer attributes in a way that can affect the grid, such grid is rebuilded and the change is immediately visible. In general I agree with removal. The effect of this issue may not be much trouble with a low number of customers, but when you have hundred of thousand this can be a major flaw since it forces the whole website to stay offline for several minutes (and usually websites with this amount of customers have also lots of online visitors at any time) when the same operation could be performed in background with a manual or scheduled reindex. Also, the customer grid is an admin only feature, and having customers to "pay" for an admin-only operation seems to be a wrong approach. As a side note i would like to stress the importance of having meaningful commit messages. All those commits with the same message (also vague) aren't useful at all when there is the need to discover what happened to the code. |
Ok, thanks for the feedback all. I just now did some more testing, to see how In contrast now, in Magento 2.3, where we have this declarative database schema and no longer seem to have So now becomes the question, why was the reindexing added to And like @giacmir says, it's probably completely unnecessary to execute this every single time when executing
@giacmir: this probably isn't correct as far as I understand it, because the Conclusion from my part: I agree with removing this |
Then we can maybe add such call in the end of every separate patch existed before |
@orlangur I think that understanding why it was added in the first place is the key. Adding that to multiple patches means that in case of upgrades that span several patches the reindex will be triggered not one time but several times, worsening the effect. |
@giacmir but we will have flexibility to run schema updates before we got some 500k of customers. With recurring approach it is running each time. |
@magento run all tests |
Hey @slackerzz Could you please sign the CLA? |
Also please look at failing tests |
@slavvka i've just signed the CLA |
Hey @slackerzz I know that Static test failure doesn't relate to your changes but since they touches the file with issues we are asking you to fix that as well to make the code better. This is how our static tests works, they check whole affected files |
The test is failing because of a php code sniffer warning:
and refers to: magento2/app/code/Magento/Customer/Model/Customer.php Lines 64 to 68 in 5b829a8
It is complaining about a How will you fix it? |
@slackerzz Could you just add to ignore it? |
@slackerzz I fixed that |
@slackerzz There's a degradation in Performance tests (Tideways EE Measurements):
|
Hello @slavvka, BUT, digging deeper into the code was discovered that:
(see dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php) and this requirements were actually not met in the current implementation because the indexer invalidation is made only if the indexer was valid, but in a place where the indexer status is not trustable. (in an after save situation, so I have actually updated a customer, but the indexer in still valid because no-one has invalidated it yet). So the choice was to ask for a reindex without checking the initial indexer condition. Said that, the detected queries were to be expected as they actually were missing before, and due now. |
Hi @slackerzz @giacmir, Lines 31 to 36 in dc7f483
Really good finding, but could you add more details how reindex was executed earlier, as grid was up to date? |
We have a big problem as described in #19469. Each deploy you end up with 10 minutes or more of downtime. It was hard to explain to the merchants. When i first faced this issue i resolved with a composer patch that you can find here and i thought that it was a good idea to share it with others by submitting a pull request. Now, after 10 months with 15 participants, 5 reviewers and 77 comments we are still arguing about 30 lines of code. |
Hi @slackerzz, thank you for your contribution! |
Description (*)
Magento/Customer/Setup/RecurringData.php
performs a Customer grid reindex at everysetup:upgrade
. In real shops, you usually have hundreds of thousands of customer and this requires 10+ minutes in my case. This is not acceptable.Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)