Repository navigation
fix(releases): lock the swap tables in the order app statements take them - #127292
Merged
Merged
Conversation
…them Postgres locks every table a statement names in the order they appear, so joins that start from sentry_release hold it while they wait for a child the swap already holds, and the swap's final lock on sentry_release deadlocks. The order comes from the us primary's statement log and the code paths that touch two of these tables in one transaction.
wedamija
approved these changes
Oct 13, 2026
This was referenced Oct 15, 2026
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.
Locks the tables in the 1207 swap in the order production statements name them, instead of children alphabetically with sentry_release last.
Postgres locks every table a statement names in the order they appear in the SQL, before it runs. Most joins on these tables start from sentry_release, so once the swap held a child they queued on it while holding release, and the swap's final lock on release could only deadlock; the retried us run died the same way one step earlier, against the latest-deploys query in the project serializer, which names releaseprojectenvironment before deploy. The order comes from a fifteen minute sample of the us primary's statement log plus the code paths that touch two of these tables in one transaction. It cuts the modelled exposure about four and a half times without removing it, so a deadlock still means rerunning the job.
cc @wedamija