OneShot

All packsScheduling & Availability CoreSolve

postgres read committed write skew double booking race condition

Two READ COMMITTED transactions can both see the same free slot and both win

A check-then-insert booking flow passes every single-threaded test and double-books the first time two people click Book at the same instant -- READ COMMITTED explicitly permits exactly this write skew.

This is one of the things Scheduling & Availability Core already handles. Bookings and availability that survive timezones, repeating events and daylight saving — without double-booking.

Buy for $993 of 3 clean-room builds passed · full refund if it fails on your machine

Is this you?

Checking availability, then inserting a booking, as two separate steps inside a READ COMMITTED transaction lets two concurrent requests both read 'this slot is free' before either one commits its insert -- both proceed, both commit, and the resource is double-booked. This isn't a rare edge case; it's the default outcome the moment two people click Book on the same slot at nearly the same instant, which is exactly when a popular slot gets clicked.

Why this one is easy to get wrong

A check-then-insert flow reads as obviously correct -- verify the precondition, then act on it -- and it passes every test written and run sequentially, one booking at a time, which is how almost all functional testing happens. PostgreSQL's own documentation states plainly that applications using anything less than SERIALIZABLE must be prepared for this kind of anomaly, but that requirement doesn't surface until two requests actually race.

What you get instead

Every booking transaction opens with pg_advisory_xact_lock(4218, advisoryLockKey(resourceId)) -- per resource, not global -- so a second concurrent request for the same resource simply waits for the lock rather than racing the first. The pack ships naive_bookings specifically with no constraint at all, purely so one acceptance check can prove the naive check-then-insert pattern genuinely does double-book in the same real database, rather than assuming the race exists.

Source: ARCHITECTURE.md 'The transaction (decided, in this order)', 'Why not the alternatives' — checkable in the pack you receive

How you actually use this

You don’t install a library or wire up an SDK. Your own coding agent builds the code in your project, and you keep it — no runtime dependency on us.

  1. Step 1

    Download and unzip

    You get a folder: the docs that tell an agent what to build, a starting skeleton, and the test suite that decides when it's done.

  2. Step 2

    Open it in Claude Code or Cursor

    Point your coding agent at the folder. Nothing to install, no account with us, no API key.

  3. Step 3

    Paste one prompt

    The pack contains the exact prompt. Paste it as your first message and leave it alone — it works through the build itself, choosing a cheaper or stronger model per task.

  4. Step 4

    Run ./verify.sh

    One command. It prints a pass or fail for every check. Green means the build is done — the same script we ran to produce the receipt on this page.

Typical build: about 22 minutes of your agent working, mostly unattended. Then you integrate the working module into your app the way you would any code you’d written yourself.

Why you can believe this

3 of 3 runs passed

We ran this pack from an empty folder 3 times and published exactly what happened — every check, the model, the token cost, the wall time. Not a testimonial, and not our opinion: the same verify.sh you run yourself. Read the full receipt →

Buy for $9914-day refund if verify.sh fails →

Related problems