PrismaGuest post
Race conditions in serverless apps: double bookings, oversold stock and lost updates
Why correct-looking checkout and booking code still oversells under concurrent requests, reproduced on Postgres, and the four fixes that hold up when every request runs in its own function instance.
What it covers
- The read-then-write bug, step by step, and why serverless concurrency makes it show up sooner
- Four fixes with SQL and Prisma ORM code: conditional writes, row locks, version columns and constraints
- When a rule spans rows and you need SERIALIZABLE with retries
- A decision table for picking a fix, and a concurrency test that proves it
- Postgres
- Serverless
- Concurrency
- Prisma ORM