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

test: get_or_upsert concurrent use #179

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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 cofin and a team as code owners September 17, 2024 22:17
Copy link

sonarcloud bot commented Sep 17, 2024

@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