mattrobenolt / mattrobenolt/ps-http-sim

Transactions unexpected behavior (Prisma)

Open
#21 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
119
Forks
7
PR merge metrics
No merged PRs in 30d

Description

Hello, I have been working on setting up ps-http-sim in front of our MySQL docker container for our local development setup to give better parity with PlanetScale's actual DBs. Everything seems to be working great except that I am encountering strange errors with some of our transactional-based operations. The two unexpected behaviors I am seeing are:

  1. Transaction operations executing out of order. In many areas of our codebase we create an object, and then reuse that object later in the transaction. For example:
await prisma.$transaction([
  prisma.user.create({ data: { id, ... } }),
  prisma.foo.create(...),
  prisma.user.update({ where: { id }, data: { ... } })
])

When using ps-http-sim I often, but not always, run into the error: An operation failed because it depends on one or more records that were required but not found. No record was found for an update. Which leads be to believe the transaction operations are being executed in parallel instead of strictly sequentially. This is also supported by the fact that every once in a while it will succeed (parallel operations just happen to be executed in the right order).

  1. The other issue is that when these transactions fail, the executed operations are not rolled back. In the example above, I have seen cases where the new foo record exists in the database after the transaction failed on the user.update operation.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or test is identified in the report. Start by reproducing the Prisma transaction example against ps-http-sim and compare its operation ordering and failure behavior with MySQL. Done means dependent operations run in order and failed transactions leave no partial records.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, mysql, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.