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 the rest_framework create/update methods #277

Open
gabn88 opened this issue Nov 20, 2024 · 1 comment
Open

Race condition in the rest_framework create/update methods #277

gabn88 opened this issue Nov 20, 2024 · 1 comment

Comments

@gabn88
Copy link
Contributor

gabn88 commented Nov 20, 2024

There exists a race condition in the rest_framework create / update methods.

I think we should use get_or_create there, to prevent this race condition from happening.

@merwok
Copy link

merwok commented Nov 21, 2024

I disagree!
Depending on how you have your model set up, you can have the database fulfill the role of lock by raising an integrity error for the duplicate object creation request, which then becomes 406 conflict or 400 error, which can be handled appropriately by clients.
Using get_or_create for a create request would muddy clear semantics.

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

No branches or pull requests

2 participants