A Rotterdam haulage firm's dock-booking app had been rewritten twice by two agencies. Every Monday at 09:00, when carriers rushed to book the week, two trucks would turn up for the same door. Each rewrite moved the bug somewhere else.
The operations manager kept a whiteboard of the real bookings next to the screen.
- Reproduce the Monday rushEngineers replayed a Monday's booking traffic against a copy of the system, 400 requests in ninety seconds, until the double booking appeared on demand.
- Find the gapTwo requests could both read “door free” before either wrote its booking. The check lived in the app, and the database never enforced it.
- Fix it where it cannot be skippedA unique constraint on door and slot, an idempotency key on every booking, and a clear “taken, here are the next three” message for the carrier who loses the race.
- Ship with the operations manager watchingThe change was rehearsed on a Sunday behind a feature flag, then switched on at 08:00 on Monday with the whiteboard still up.
-- before: availability checked in application code onlySELECT count(*) FROM bookings WHERE door_id = $1 AND slot = $2;INSERT INTO bookings (door_id, slot, carrier_id) VALUES ($1, $2, $3);ALTER TABLE bookings ADD CONSTRAINT one_truck_per_door UNIQUE (door_id, slot);INSERT INTO bookings (door_id, slot, carrier_id, request_key) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING RETURNING id;- Load replay3 double bookings in 400 requests, each pair written within 40 ms of the other.
- EngineerA race between the check and the insert. The database now refuses the second truck, and the carrier sees the next free slots.
- Your operations managerApproved for Monday 08:00 after the Sunday rehearsal.