Saga pattern
Published Updated
What is Saga pattern?
A multi-step workflow of local transactions with compensating actions that address earlier completed steps when a later step fails.
A local transaction saves changes within one service. For example, checkout reserves stock, charges payment, then arranges shipping. If shipping cannot be arranged, a saga can refund the charge and release stock. Compensation is a new business action, not erasing history. It can fail too, and other users may see intermediate states.
When you would use it
Use it for workflows across services that cannot share one atomic transaction, where all changes would succeed or fail together.
Common operations
- Record each completed step and its compensating action.
- Retry safe steps and escalate failed compensation.