Scenario: two users hit Book on the last seat at the same moment. The code checks that the seat is available, charges the card, then marks the seat as booked. Who gets the seat?
Both of them. Run the same code with 50 users and all 50 are told their booking is confirmed.
This is the first trap in a series on designing a booking system that holds up under real traffic. It is a scenario, not an incident report: a bug that many developers write, ship and only discover when two customers arrive at the same venue holding the same ticket. I built it as a runnable trap in the interview-traps repo , with the broken code, the fix and a test that proves the fix against a real Postgres database. You can also step through the replay on the Labs page .
Why booking code that passes every test still double-books
The buggy version looks reasonable. It reads, checks, does the slow work, then writes:
const { rows } = await db . query ( "SELECT status FROM seats WHERE id = $1" , [ seatId ] ) ; if ( rows [ 0 ] .…