#33386 Fix triggers management issue during setup:upgrade#40643
#33386 Fix triggers management issue during setup:upgrade#40643Nuranto wants to merge 4 commits into
Conversation
|
Hi @Nuranto. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
@magento run all tests |
|
@magento run all tests |
engcom-Hotel
left a comment
There was a problem hiding this comment.
Hello @Nuranto,
Thank you for the contribution!
It seems that due to the recent PR changes, the database compare test has started failing. Please look into this issue.
|
@magento run all tests |
@engcom-Hotel, In order to fix the database compare test failure, I have updated the fix for "Migrating the change-log tables during setup:upgrade without rebuilding the triggers. The test failure is fixed now. Moving it to Review again. |
engcom-Hotel
left a comment
There was a problem hiding this comment.
Failed tests seems flaky to me or does not related to this Pr. Hence confirming this PR.
Description (*)
During
setup:upgrade, theIndexer\Setup\Recurringclass unconditionally drops and recreates all database triggers for every scheduled indexer by callingunsubscribe()/subscribe()in a loop. This acquires exclusive table locks even when no trigger changes are needed, causing unnecessary downtime on large installations.This PR:
unsubscribe()/subscribe()loop with a single call toTriggerCleaner::removeTriggers(), which only recreates triggers whose SQL statements have actually changed.TriggerCleanerby extracting logic into ashouldUpdateTrigger()method that performs a normalized full-statement comparison instead of a partialstr_containscheck. This also detects obsolete statements from removed views.Fixed Issues (if relevant)
savefromscheduleslowing it down immensely #33386Manual testing scenarios (*)
bin/magento setup:upgradeon an instance with multiple scheduled indexers and verify triggers are only recreated when their SQL actually differs from the DB state.setup:upgrade, and verify that stale trigger statements from the removed view are cleaned up.setup:upgradetwice in a row with no configuration changes and verify no triggers are dropped/recreated on the second run (no unnecessary exclusive locks).Questions or comments
Contribution checklist (*)