Saga Pattern 00:00:01 An order crosses three owners A customer buys the last item. Orders can record a purchase, inventory can reserve stock and payments can charge the card. Each service can commit its own change. How does the customer get one intelligible outcome? The orchestrator receives an order request and creates a saga record. It commands Orders to create the order. Orders commits locally and replies. The order is PENDING. Inventory confirms the reservation. Both the order and the stock change are locally durable; payment still has to succeed. It commands Payments to charge the customer. This is the pivot. The payment succeeds. The order is confirmed and the saga completes. A saga records progress across local transactions. Success on the happy path tells us very little about what happens when money or stock moves and the next call fails. 00:01:01 Undo the business effect Run the order again with payment refused. An inventory reservation has already committed. A rollback on the payment database cannot undo another service's committed reservation. Which service has the information to release it? The order exists and the stock is reserved. Both are committed. The orchestrator commands Payments. Payments answers: refused. The saga must compensate. The newest finished step is undone first. Then the order is marked as cancelled. It is not deleted. All compensations are complete. The saga failed gracefully. Compensation is a new business operation with its own failure modes. A released item may be sold immediately, so returning to the earlier business state cannot rewind the history of the world. 00:01:55 Who decides which step comes next? The same order can progress through published events instead of a central coordinator issuing commands. Listen for which service owns each next reaction, including the reactions to failure. Orders commits and publishes. Inventory reacts. Inventory commits and publishes. Payments reacts. Payments publishes. Orders confirms the order. If the charge is refused, the failure event reaches two services. Each undoes its own step. Orders and inventory recognize the failure event and apply their own defined compensations. Duplicate events require repeat-safe handlers. Local reactions remove one central caller, but somebody still has to explain the entire chain to an operator. Record identifiers and state transitions that let the operator reconstruct a particular order. 00:02:49 The coordinator disappears mid-order A durable saga record says a stock reservation started. Before the confirmation is safely recorded, the coordinator stops. On restart this state has two explanations, and blindly reserving again could take another unit. The log says the stock step has started. The orchestrator dies. Nobody has written that the stock is reserved. It finds a step that started and has no result. Inventory recognises the key and returns the old result. Nothing is reserved twice. The result is logged and the saga goes on to the payment. Stable operation identifiers and recorded results let a repeated command recover an earlier outcome. Persisting a step name alone cannot make an external action safe to repeat. 00:03:35 Silence after a command The hardest payment response is silence. A timeout says the caller did not receive the answer in time. It does not say whether a charge occurred. Commit to a course of action only after accounting for both possibilities. The command goes out. The reply is lost. The card may be charged or not. Retries with backoff find nobody at home. Payments is back. It refunds if the charge exists, and refuses a late charge if it does not. After the payment outcome is reconciled or cancelled according to its contract, stock is released and the order can be cancelled. The original customer should see a pending state while the outcome is uncertain. Saga correctness lives in the recovery, compensation and reconciliation paths just as much as it does in the successful purchase.