Repository navigation
Conversation
Signup and create user check the email, then insert. Two requests with the same email can both pass the check. The unique index stops the second insert, which answered 500.
Patch the email check to find nothing, so the insert hits the unique index the way two requests at once do.
Member
|
Thanks for your interest and efforts, but please follow the rules of the repository. We ask people to only open PRs when it's explicitly requested by maintainers.
I will close this for now to keep things clean. |
Author
|
Sorry, I missed the rule about starting with a discussion. I will open one and link this PR there |
Author
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.
Signup and create user check if the email is free, then insert. If two requests with the same email come in together, both pass the check. The unique index on user.email stops the second insert, and that request returns a 500.
One after the other: 200, then 400.
At the same time: 200 and 500.
No duplicate user gets created. Only the response is wrong.
This change catches IntegrityError around crud.create_user in both endpoints, rolls back, and returns the same 400 as the check. Two new tests cover it.
I found this with
racetrap, a tool I am building that forces the order of SQL statements between two requests:https://github.com/w-rahul/racetrapAfter this change it reports no races for these requests.