Delete records on secondary on fkey constraint error #1638
Merged
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.
Description
Sometimes the secondary gets into a weird state (either bad export from primary or bad sync into secondary) where there's a fkey constraint. This fix allows for two things to happen
Tests
I first verified that clearing the state and re-syncing fixes the constraint error and it does.
I couldn't repro the exact scenario with the fkey constraint in the db locally. What I did was verify the error in loggly to determine what I should look for and added it to an existing flow I have already tested for non-contiguous clock values..
How will this change be monitored?
https://audius.loggly.com/search#terms=%22Sync%20error%20for%22&from=2021-07-11T18:35:54.997Z&until=2021-07-12T18:35:54.997Z&source_group=