wtf( )unctionsystem design, drawn
← all problemsDistributed SystemsHard

Charged for a booking that doesn't exist

Booking a trip charges the card, reserves a seat, then awards points — three services, three databases. The seat reservation fails after the charge succeeded, and no code path refunds it.

There is no transaction spanning three services. Each step committed locally and there is nothing to roll back.

Add what owns the sequence and knows how to undo it.
Components — tap one, then tap a slot on the diagram
!The card was charged. Then the seat turned out to be sold.

Outside every boundary: Payments (charged; FAILED: money taken), Inventory (sold out; FAILED: failed), Book trip, Loyalty, an empty slot for the owns the sequence Connections: Book trip calls owns the sequence (step 1) owns the sequence calls Payments — charge · refund on failure (step 2) owns the sequence calls Inventory — reserve (step 3) owns the sequence calls Loyalty (step 4)

Paymentschargedmoney taken
Inventorysold outfailed
Book trip
Loyalty