This PR acts as a reproducer for get_or_upsert raising IntegrityErrors for UniqueConstraint when sending multiple requests at once.
I added a UniqueConstraint to the user_account_role table which basically means, that one cannot have the same role multiple times.
In the controller I needed to remove the if statement, otherwise the get_or_upsert would not create anything in this case. However there's another bug in the original version, as created is not defined if the first condition is false.
The test contains 1 or 4 equal queries, two times in a row. When making a single request (which assigns the tag) the second request reports that the role was already assigned and succeeds.
In case of 4 queries at the same time, only the first query succeeds, the remaining three fail.
This PR is not meant to get merged like this, but as a starting point for discussion.
Description
This PR acts as a reproducer for
get_or_upsert
raisingIntegrityErrors
forUniqueConstraint
when sending multiple requests at once.I added a
UniqueConstraint
to theuser_account_role
table which basically means, that one cannot have the same role multiple times.In the controller I needed to remove the
if
statement, otherwise the get_or_upsert would not create anything in this case. However there's another bug in the original version, ascreated
is not defined if the first condition is false.The test contains 1 or 4 equal queries, two times in a row. When making a single request (which assigns the tag) the second request reports that the role was already assigned and succeeds. In case of 4 queries at the same time, only the first query succeeds, the remaining three fail.
This PR is not meant to get merged like this, but as a starting point for discussion.