Interactive Transaction concurrent writes cause Prisma to hang
See original GitHub issueBug description
Most likely related to https://github.com/prisma/prisma/issues/8707
Here is a minimal repo, using postgres DB and Prisma 3.9.1: https://github.com/danielwong2268/test-prisma
When running several concurrent transactions, under some conditions Prisma hangs. Some variables that were toggled was the number of concurrent transactions, whether locking through SELECT FOR UPDATE
was used, and whether a delay was introduced to the transaction. A different combination of these three variables yielded different results.
Further description and observations in the readme.
How to reproduce
Go to minimal repo in Bug description and run through steps. CONCURRENCY
, WITH_LOCK
, and ADD_DELAY
variables can be changed within the script.
My observations are here: https://github.com/danielwong2268/test-prisma#current-behavior
Expected behavior
Running with CONCURRENCY=10 and WITH_LOCK=true and ADD_DELAY=true should work, and the final id should be 1 + 10 = 11.
Prisma information
datasource db {
provider = "postgresql"
url = "postgresql://postgres:postgres@localhost:5432/test-db"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["interactiveTransactions"]
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User? @relation(fields: [authorId], references: [id])
authorId Int?
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
}
Environment & setup
- OS: Mac OS 11.5.2
- Database: Postgres 13.3
- Node.js version: v14.17.3
Prisma Version
prisma : 3.9.1
@prisma/client : 3.9.1
Current platform : darwin
Query Engine (Node-API) : libquery-engine bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : bcc2ff906db47790ee902e7bbc76d7ffb1893009
Studio : 0.457.0
Preview Features : interactiveTransactions
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:7 (4 by maintainers)
Top GitHub Comments
@christie-mathews we are actively working on it. We will let you know once we release an improvement.
We have a fix for this over https://github.com/prisma/prisma/pull/12563 and here https://github.com/prisma/prisma-engines/pull/2811
They will need to be reviewed and tested properly but the test should hopefully be in the next release.