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
[Improvement] Prevent db errors on index updates on classes rebuild #16871
[Improvement] Prevent db errors on index updates on classes rebuild #16871
Conversation
Review Checklist
|
It seems like the pipeline did crash because of random 500er errors. The actions could not be loaded. Could you please run it again @mcop1 or @wisconaut |
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.
Hello @lukadschaak ,
we would like to have your changes in the core and would value the error resilience above the performance impact.
But I noticed a problem while executing the command. E.g. here https://github.com/pimcore/pimcore/pull/16871/files#diff-38cc27289cd8997402eaa2b3921c32292050c33ff9ad2f59c5606c079bb35484R55
you use $columnName
as parameter for indexDoesNotExist
method. But it includes quotes for the identifier, therefore the method will return true even if the index exists. I think we should rather use $indexName
as a parameter? What do you think?
If you agree, could you please check the other occurrences too? Thank you for your efforts!
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
@mcop1 Thanks a lot for your review! You are absolutely right with your suggestion. Maybe you can take a look at the last commits from me. I followed your sugestion and used I also renamed the other occourance as well, because it looks more suitable for me. But this could be easily reverted. Also I want to mention, that I was not able to check the multicolumn cases. I don't know how to reproduce this. |
I have read the CLA Document and I hereby sign the CLA |
Co-authored-by: Jacob Dreesen <jacob@hdreesen.de>
…e can contain quotes
ee91afd
to
afd06cb
Compare
Quality Gate passedIssues Measures |
Looks good to me, thank you again! |
Changes in this pull request
Resolves #13195
Long time ago, i stumbled upon the errors that MySQL based databases throw, when you try to add an index which is already there or to delete an index that is not there:
An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP INDEX 'p_index_name'; check that it exists
Some explaining can also be found in the connected issue.
This PR add existence checks for those indexes. Advantage: Cleaner solution, Disadvatage: Slightly more time consuming. (See screenshots).
I did not find any good ways to write tests for that, so i tried that on local machine with the setup explained in the System Requirements Docs. Tested with MySQL 8.3.0 and MariDB 10.11.5
Additional info
I created a Pimcore class
car
with a name and a sku attribute. I updated the class via the Admin backend and looked in the profiler which db queries were executed. Both time without changing the class attributes at all.Database queries without refactoring
Database queries with refactoring