Saga Pattern

Coordinate a long workflow through compensatable local transactions.

Problem

A business workflow spans systems that cannot share one transaction.

When to use it

  • Steps have explicit compensations
  • Pending states are acceptable

When not to use it

  • One database transaction suffices
  • Actions cannot be compensated and ambiguity is unacceptable

Minimal example

Reserve stock → authorize payment → request fulfillment. On rejection, void authorization and release reservation.

Tradeoffs

  • Compensation is not time travel
  • Requires durable state, idempotent steps, and operations tooling