noCV
STOCK-105 · Checkout under contention

Decide the winner when payment and expiry arrive together

Practice briefTaskExpert

Payment confirmation and the expiry sweeper reach reservation R-42 at the same instant. Today both handlers succeed and a paid order loses its stock.

Focused work estimate
5h + prerequisites
Priority in the scenario
High
Engineering practice
Concurrency control · Temporal invariants · Distributed callbacks · Failure design

Estimated field mix

  • Backend50%
  • Distributed systems30%
  • Database engineering20%

Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.

Your next step

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

  • Document one deadline rule using server time and apply it in both handlers.
  • Exactly one terminal transition wins under concurrency.
  • A payment arriving after a lost hold enters an explicit exception path without reserving unavailable stock.

Implementation constraints

  • Payment success alone does not authorize negative stock; retain callback identity for replay.

Verification to include

  • Exercise callback just before, at, and just after the deadline.
  • Run callback and sweeper concurrently, then replay both and inspect one terminal audit.

Deliverables

  • Deadline decision record, race tests, and late-payment exception contract

Rollout and recovery

Shadow-classify deadline decisions first; rollback new routing while preserving terminal decisions already recorded.

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.