-
-
Couldn't load subscription status.
- Fork 147
Closed
Labels
Description
I've created a repo that reproduces this issue: https://github.com/derekchiang/postgres-bug
Basically, I'm running some code in a serializable transaction like this (pseudocode):
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE
const userCount = select count(*) from missions
if (userCount == 0) {
insert into users default values
}
COMMIT
Now, when you run this transaction many times in parallel, you'd think that only one row would be created. However, as you can see from the test in the repo, more than 1 rows wound up getting created.
It's not clear to me whether this is a bug in Slonik or Postgres, or if I'm fundamentally misunderstanding something. But I thought I'd put it here in case it's an issue in Slonik.
bausmeier and jorinvo