Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backup/restore): Warn users of integrity violations during backup/restore #44705

Merged
merged 15 commits into from
Feb 24, 2023

Conversation

hubertdeng123
Copy link
Member

@hubertdeng123 hubertdeng123 commented Feb 15, 2023

Some users are getting this error when restoring from a backup

UniqueViolation('duplicate key value violates unique constraint "sentry_...

We should wrap the model saves in one single atomic transaction so that none of the data is saved if an error happens. On integrity error, let's warn users to use a clean db.

Also added some quick tests are backup/restore logic to make sure it doesn't error out

@github-actions github-actions bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Feb 15, 2023
@github-actions
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@hubertdeng123 hubertdeng123 marked this pull request as ready for review February 16, 2023 19:03
@hubertdeng123 hubertdeng123 requested a review from a team February 16, 2023 19:05
@hubertdeng123 hubertdeng123 changed the title fix(backup/restore): Handle duplicate key violation exceptions fix(backup/restore): Warn users of integrity violations during backup/restore Feb 22, 2023
Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

# these errors come from restoring on a different version of Sentry or not restoring
# on a clean install.
except IntegrityError as e:
warningText = ">> Are you restoring from a backup of the same version of Sentry?\n>> Are you restoring onto a clean database?\n>> https://github.com/getsentry/sentry/issues/new/choose"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I was unclear, if we have the link we should also have the "if neither, then open an issue here:" text. 🐭

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah added 😀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@chadwhitacre chadwhitacre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 :shipit:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants