Compensating Transaction
PronunciationKOM-pen-say-ting tran-ZAK-shun
Definition
A compensating transaction undoes the effect of an earlier step by performing an opposite action, such as refunding a payment, when a later step in a multi-step process fails.
Where you hear it
In saga and microservice designs, booking and payment flows, and discussions where one database transaction can't span services.
Examples
Shipping failed, so the saga runs a compensating transaction to refund the payment.
Each step needs a defined compensation.
The refund is a compensating transaction for the charge that succeeded before shipping failed.
Common mistake
Assuming it restores the exact earlier state. A refund isn't "never charged"; other effects (emails, logs) remain.
Don't confuse with
A database rollback, which erases uncommitted changes. A compensating transaction acts after commit with a new, opposite change.
Say it at work
- In a meeting or chat
What's the compensation for this step?
- In an email or ticket
Make the compensation idempotent.
Keep exploring
More in Architecture & Design