Skip to content

fix(organizations): Add select_for_update to prevent race condition in set_user_for_organization_member#108344

Merged
vgrozdanic merged 2 commits intomasterfrom
fix/select-for-update-org-member
Mar 17, 2026
Merged

fix(organizations): Add select_for_update to prevent race condition in set_user_for_organization_member#108344
vgrozdanic merged 2 commits intomasterfrom
fix/select-for-update-org-member

Conversation

@vgrozdanic
Copy link
Copy Markdown
Member

In set_user_for_organization_member, the OrganizationMember query at
line 309 fetches, mutates (.set_user()), and saves within a
transaction.atomic() block but without select_for_update(). This
means concurrent requests can read the same row simultaneously and
overwrite each other's changes, causing a race condition.

Adding select_for_update() ensures the row is locked for the duration
of the transaction, so only one request can modify the member at a time.

…n set_user_for_organization_member

The org_member query inside the transaction.atomic() block was missing
select_for_update(), allowing concurrent requests to read and overwrite
each other's changes when setting a user on an organization member.
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 17, 2026
@getsantry
Copy link
Copy Markdown
Contributor

getsantry bot commented Mar 11, 2026

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Mar 11, 2026
@vgrozdanic vgrozdanic removed the Stale label Mar 16, 2026
@vgrozdanic vgrozdanic marked this pull request as ready for review March 16, 2026 08:39
@vgrozdanic vgrozdanic requested a review from a team March 16, 2026 09:43
@vgrozdanic vgrozdanic merged commit 37b85db into master Mar 17, 2026
78 checks passed
@vgrozdanic vgrozdanic deleted the fix/select-for-update-org-member branch March 17, 2026 13:45
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2026
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.

2 participants