Skip to content

Conversation

FranzForstmayr
Copy link
Contributor

@FranzForstmayr FranzForstmayr commented Sep 17, 2024

Description

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.

@FranzForstmayr FranzForstmayr requested review from a team and cofin as code owners September 17, 2024 22:17
Copy link

@FranzForstmayr FranzForstmayr changed the title get_or_upsert concurrent use test: get_or_upsert concurrent use Sep 17, 2024
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

Successfully merging this pull request may close these issues.

1 participant