[2.1] Never delete all changelog rows #13577
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See also #13575 (port to 2.1)
When cleaning ALL changelog rows, indexes get confused after a MySQL restart. The changelog version ids can start over at 1, and mview_state will be ahead of it.
This causes incremental indexing to simply not execute.
Description
To prevent this, we always keep the highest version id row, which makes MySQL handle auto_increment as expected, even after a restart.
Fixed Issues (if relevant)
See Cloud issue 14833.
Manual testing scenarios
php bin/magento indexer:set-mode schedule
.Actual results (before this PR):
At step 5, zero entries remain in the _cl table.
At step 8, the changes never index.
Expected results:
At step 5, one entry remains in the _cl table.
At step 8, the changes successfully update.
Contribution checklist