Pizza Saga Kitchen
One order crosses four independent space-station services. Coordinate every step, survive an oven failure, and restore the customer's tokens without one giant lock.
π§ Before we start
Clinic Vector Clocks showed that separate computers hold separate knowledge. Today, a saga coordinates a long job across separate services. If a later step fails, the saga asks earlier services to perform meaningful undo actions called compensations.
Plan the forward journey
Tap the service actions in order. Secure the customer's place and payment before asking the kitchen to spend ingredients and oven time.
Follow a partial failure
Move the order through each service. The first three finish, but the oven service is offline. Notice that completed work does not disappear by itself.
Compensate in reverse
The oven failed after three services finished. Undo the completed effects from newest to oldest, so dependencies unwind safely.
Debug the duplicate charge
A buggy coordinator retries the whole order immediately after failure. The bank receives a second charge. Choose the recovery rule that protects the customer.
π What you learned
- A saga coordinates one long workflow across independent services.
- Each forward step records a real effect owned by one service.
- A later failure does not automatically erase earlier successful work.
- Compensations are meaningful undo actions, not time travel.
- Completed effects are usually compensated in reverse order.
- Closing or compensating a failed attempt before retrying prevents duplicate side effects.