Saga

Problem

An order: 1. reserves inventory, 2. charges payment, 3. books delivery. Step 3 fails after steps 1 and 2 succeeded. You cannot simply roll back three independent systems like one database transaction.

Solution — Saga

Model the operation as steps with compensating actions.
Each completed step has a compensating action:
* Reserve stock → release the reservation.
* Charge card → issue a refund.
If booking delivery fails, those actions undo the earlier steps' business effects.
Reserve stock ✓
Charge card   ✓
Book delivery ✗
      ↓
Refund card
Release stock
For example, Azure Durable Functions records workflow progress and runs the steps; you write the compensating actions it calls after failures.
Core idea: sagas handle distributed business operations through coordinated steps and compensation.