"Unique constraint failed on the fields" when using upsert #14868
Labels
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
kind/bug
A reported bug.
team/client
Issue for team Client.
topic: prisma-client
topic: upsert
nested upsert
Milestone
Bug description
I was messing around with attempting to create a mutex lock using the db and thought I could do it via an
upsert
but it looks like the upsert can fail due to a race condition. The schema and code used to generate this error is in the "How to reproduce" section.Here's the error with DEBUG="*" on:
How to reproduce
With the following model in the schema:
Run this code:
Expected behavior
I'd expect one transaction to create the row and another to update the row.
Prisma information
Here's the model:
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: