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

Race condition in realm creation #21160

Open
alexmv opened this issue Feb 16, 2022 · 5 comments · May be fixed by #22006
Open

Race condition in realm creation #21160

alexmv opened this issue Feb 16, 2022 · 5 comments · May be fixed by #22006

Comments

@alexmv
Copy link
Collaborator

alexmv commented Feb 16, 2022

It's possible for two realm creations with the same name to race, which triggers a 500 and raises an exception:

duplicate key value violates unique constraint "zerver_realm_subdomain_key"
DETAIL:  Key (string_id)=(duplicate-realm-name) already exists.

This is raised by realm.save() in do_create_realm, which is (correctly) inside a transaction.atomic() so we don't get inconsistent state in the database. The only problem is the potential user experience; accounts_register in zerver/views/registration.py should catch the IntegrityError that is so raised, and return a 400, not a 500.

@zulipbot
Copy link
Member

Hello @zulip/server-production members, this issue was labeled with the "area: production" label, so you may want to check it out!

@cognusion
Copy link
Sponsor Collaborator

@zulipbot claim

@zulipbot
Copy link
Member

Welcome to Zulip, @cognusion! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!

Here's some tips to get you off to a good start:

As you work on this issue, you'll also want to refer to the Zulip code contribution guide, as well as the rest of the developer documentation on that site.

See you on the other side (that is, the pull request side)!

@zulipbot
Copy link
Member

zulipbot commented May 27, 2022

@cognusion You have been unassigned from this issue because you have not made any updates for over 14 days. Please feel free to reclaim the issue if you decide to pick up again. Thanks!

@cognusion
Copy link
Sponsor Collaborator

PR #22006 has been open for this issue. :patientlywaiting: on that 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants