Reserve the last unit atomically
Two checkouts both read one remaining wheelset before either writes a reservation. Both succeed, leaving the warehouse with available stock of minus one.
- Focused work estimate
- 3h 30m + prerequisites
- Priority in the scenario
- Urgent
- Engineering practice
- Concurrency · Transactions · Invariant testing
Estimated field mix
- Database engineering60%
- Backend40%
Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.
Review it, then add it to your workspace.
The board opens an editable draft; nothing is saved until you confirm it. Sign-in and workspace permissions apply, and Demo boards remain ephemeral.
Project context
A fictional retailer sells bicycle parts from East and West warehouses. Cart reservations last ten minutes, payment callbacks arrive late, and warehouse counts occasionally need correction. The exercise has no real orders or payment integration.
Setup prerequisites
- Relational modeling
- Concurrent API requests
- State transitions
Preceding work
Complete these dependencies, or supply their agreed outputs before taking this ticket.
Acceptance criteria
- At most one of two concurrent requests for the last unit succeeds.
- Availability never drops below zero for committed reservation transactions.
- An insufficient-stock failure creates neither a reservation nor an audit success.
Implementation constraints
- The database must enforce correctness when requests arrive at different API processes.
Verification to include
- Run overlapping reservations against one unit and inspect final state.
- Inject a failure before commit and prove the available quantity is restored.
Deliverables
- Atomic reservation path and deterministic race reproduction
Rollout and recovery
Canary with one synthetic SKU under contention; disable reservation writes if the invariant monitor fails.
Value of the work
For the engineer: Practice inventory invariants and timed state transitions while balancing customer experience with operational repair.
For the team: Inspect an engineer's handling of overselling, delayed callbacks, warehouse boundaries, and reversible schema changes.
Evidence boundaries
Outcome Evidence: Tests, patches, and runbooks are requested deliverables. They become Outcome Evidence only through a qualified Mission and immutable Evidence IDs.
Ownership Evidence: Independent adaptation must be observed under a declared verification policy and cite immutable Evidence IDs. Completing a planning ticket establishes no Ownership Evidence.