jargon

Comparison

Compensating transactionvsSaga

Compensating transaction

you cannot roll back the payment you already captured, so you issue a refund that puts the world approximately back.

A business-level operation that semantically reverses an earlier committed one. It is the only rollback available once a step has left your system. The gap between "reversed" and "never happened" is where the interesting bugs live: the email was sent, the webhook fired, the inventory was briefly visible as sold.

Full entry →

Saga

you break the cross-service operation into local transactions and write an undo step for each one, because there is no shared rollback.

A sequence of local transactions across services, with a compensating action for each step, so that a failure part-way is unwound rather than rolled back. It buys availability and loose coupling at the cost of never having true atomicity: intermediate states are visible, and compensation is not the same as undo. Every saga step must be idempotent, because retries are guaranteed.

Full entry →

Related comparisons