FIX Correctly clear table and reset auto increment #11333
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.
Follow-on from #11309 and #11319
We can't use the ID value as the existing implementation does, because if we created some records and then deleted them all, the max ID will be
0
ornull
(depending on how MySQL reads that), which means we won't reset the auto increment.We also can't rely on fetching the current auto increment value like the original implementation did because that's cached in MySQL 8.0 which is what caused the original failure.
Instead, we just always reset the auto increment. It'll be faster than a truncate, and it's better than trying to mess with the cache settings for the table stats or running
ANALYZE TABLE
(which I did try but it caused other problems).Issue