-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
DRF uses .save() when creating a new object via the REST API. When an object already exists (like by unique field value) then the error message is returned that the object exists. It works nicely in an example or in a test of two requests one after another.
In more real world example things like AJAX requests may get bit floody sending multiple requests nearly at the same time. Web application workers start processing them and for all/most of them the object does not exist. First one succeeds and the other ones end up throwing IntegrityError (in PostgreSQL, "duplicate key value violates unique constraint").
It would be good if creating (updating also?) an object would use some locks, get_or_create and/or other solution to be request flood-proof.