Log or raise on unexpected duplicated entry warnings during INSERT IGNORE#100
Merged
Conversation
added 7 commits
June 23, 2021 19:13
a09a2a4 to
371bbef
Compare
shuhaowu
approved these changes
Jun 28, 2021
xliang6
approved these changes
Jul 16, 2021
xliang6
left a comment
There was a problem hiding this comment.
Looks good to me. I would change the PR title to Log or raise on unexpected duplicated entry warnings during INSERT IGNORE to be more clear.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes https://github.com/Shopify/shopify/issues/302218
Today when migrating a schema that ends up violating a UNIQUE constraint, the records to the new shadow table is dropped silently. This may cause huge silent data loss when, for example, a column is dropped that is part of a UNIQUE index, without modifying or dropping the index. Same problem can occur if we change collation, causing a unique index to ignore case and drop rows silently.
This PR attempts to make these drops halt the migration and alert the operator that this is happening, making it possible to resolve the issue before migrating again. This is done by inspecting any warnings in-case we can see that the number of inserted rows were lower than we expected, signalling ignored rows. These warnings are in most cases fine, since PK duplicates may occur by design, but other constraints should not.