-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Restore UNIQUE_CHECKS mysql variable to its original value when done … #32286
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
Restore UNIQUE_CHECKS mysql variable to its original value when done … #32286
Conversation
Hi @hostep. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
…with changing the database structure. This prevents potentially inserting duplicated values while manipulating data in the setup:upgrade command.
a25c2c8
to
2979876
Compare
@magento run all tests |
Hi @ihor-sviziev, thank you for the review.
|
@magento run Static Tests |
@sivaschenko @sidolov @gabrieldagama, it seems like p1 priority should be set for this issue. What do you think? Note: it would be great to coved this PR with some integration/setup-integration test, but not sure if it will be easy |
Milestone set to 2.5 as this change is backwards incompatible. Is it possible to cover the issue with integration tests (i.e. adding a test module trying to install duplicated data)? |
@sivaschenko: I strongly disagree with the BiC statement. You don't want people to have corrupt databases right? Rows in a database table should be unique according to the unique key which is set on the table. Currently Magento doesn't protect your database from this by disabling unique_checks during I would like to ask you to reconsider, thanks! |
@hostep @ihor-sviziev thanks for bringing up the concern! Is there any functional impact of duplicated DB entries except MySQL dump/import? |
Not as far as I could see.
This was explained in #32283, but short summary: I've seen 2 separate instances of this same bug happening, it was both times triggered by this script part of core Magento. This patch only executes when you upgrade from Magento < 2.2.0 to Magento 2.2.0 or higher. In our case we ran into this when upgrading a shop from 2.1.11 to 2.3.6 and a different shop from 2.1.16 to 2.3.6-p1. From what I could determine, the Maybe good to know, but I can tell you with 100% certainty that this PR here fixes the issue we had on 1 of those two shops, because I had a way to reproduce the problem on the staging environment of that shop. |
This one might be also related, but not sure #29804 |
Thank you for the detailed explanation @hostep . I will change the milestone to 2.4 and launch an internal approval process for BIC. In case the BIC will be approved - we'll be able to deliver it to 2.4. |
Thanks @sivaschenko: please also consider backporting to 2.3 if possible 🙂 |
Internal approval request: https://jira.corp.magento.com/browse/MC-41144 |
@sivaschenko: is there any sort of progress on this? I accidentally bumped into another report for the same problem, so I'm definitely not the only one who ran into this problem (And did my comment in that other ticket for some reason moved this from "to approve" to "ready for testing"? That's wierd) |
@hostep approval is in progress |
I moved back to "to approve" status. |
Hi folks, asking again after 2 months. PR has prio 1, still no movement, any idea what's blocking this and can I help out somehow? |
@gabrieldagama @sivaschenko @sidolov could you help with it? |
Any update regarding this PR? We have now more and more clients coming with upgrade requests and I think this should be fixed asap. |
@kandy maybe you can move forward approval for such important fix? |
Unfortunately, I'm not part of the Community Engineering team. I think the best person to ping is @sidolov. |
Hi @Den4ik, thank you for the review. |
Hi @hostep, thank you for your contribution! |
Finally, it got merged! 🎉 |
…with changing the database structure. This prevents potentially inserting duplicated values while manipulating data in the setup:upgrade command.
Description (*)
See #32283
When approved, please please please consider backporting this to Magento 2.3.7, this is too important to be ignored for 2.3 in my opinion.
According to Magento core devs I spoke to on Slack in the past few days, there is an underlying problem where connections should be closed and opened again between the schema manipulation and the data manipulation in order to reset these mysql variables. But that's not happening.
So this is only a workaround, but since the same workaround was implemented for the
FOREIGN_KEY_CHECKS
and others, it makes sense to also do this forUNIQUE_CHECKS
until the root cause is found, since it's an easy fix which should not cause issues.I have no intention to write automated tests for this change, I already spend more then 10 hours on dealing with the consequences of this issue and then an hour on finding an appropriate solution, I can't invest more time in adding automated tests, sorry!
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
UNIQUE_CHECKS
variable, the RecurringData script makes it easy to test. For example, in the Magento\SalesSequence\Setup\RecurringData::install method, add:bin/magento setup:upgrade
Before this PR, it outputs:
After this PR, it outputs:
Questions or comments
Contribution checklist (*)