Skip to content

fix(releases): lock the swap tables in the order app statements take them - #127292

Merged
ldelvoye merged 1 commit into
masterfrom
ldelvoye/fix/release-swap-app-lock-order
Oct 13, 2026
Merged

ldelvoye merged 1 commit into
masterfrom
ldelvoye/fix/release-swap-app-lock-order

Conversation

@ldelvoye

Copy link
Copy Markdown
Member

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

…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.
@ldelvoye
ldelvoye requested a review from a team as a code owner October 13, 2026 18:39
@ldelvoye
ldelvoye requested a review from wedamija October 13, 2026 18:39
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 13, 2026
@ldelvoye
ldelvoye merged commit 66f314c into master Oct 13, 2026
88 of 89 checks passed
@ldelvoye
ldelvoye deleted the ldelvoye/fix/release-swap-app-lock-order branch October 13, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants