Skip to content

Integrity problems with object creation #1859

@riklaunim

Description

@riklaunim

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions