Skip to content

fix(authentication): handle concurrent first-login race condition#732

Open
bencap wants to merge 1 commit into
release-2026.2.3from
bugfix/bencap/703/get-current-user-race-condition
Open

fix(authentication): handle concurrent first-login race condition#732
bencap wants to merge 1 commit into
release-2026.2.3from
bugfix/bencap/703/get-current-user-race-condition

Conversation

@bencap
Copy link
Copy Markdown
Collaborator

@bencap bencap commented May 12, 2026

When multiple servers process a user's first login simultaneously, each may query, find no existing record, and attempt to INSERT. The losing request raised an unhandled IntegrityError.

  • Wrap the commit in a try/except IntegrityError block
  • On collision: rollback and re-fetch the existing user record
  • Add a test that simulates the race and asserts the correct user is returned with exactly one DB row

@bencap bencap linked an issue May 12, 2026 that may be closed by this pull request
When multiple servers process a user's first login simultaneously,
each may query, find no existing record, and attempt to INSERT.
The losing request raised an unhandled IntegrityError.

- Wrap the commit in a try/except IntegrityError block
- On collision: rollback and re-fetch the existing user record
- Add a test that simulates the race and asserts the correct user
  is returned with exactly one DB row
@bencap bencap force-pushed the bugfix/bencap/703/get-current-user-race-condition branch from 9ede58a to 07c971b Compare May 12, 2026 21:41
@bencap bencap requested review from jstone-dev and sallybg May 12, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition in get_current_user on first sign-in

1 participant