What is a compensating transaction?

Definition

Distributed workflows often cannot roll back every system through one database transaction. Instead, each completed side effect can define a compensation, such as canceling a reservation or issuing a reversing entry, that returns the business process to an acceptable state.

Compensation is not always a perfect erasure, so the workflow must record what happened and make each recovery action safe to retry. Agents should invoke only predefined compensations rather than improvising a reversal from natural-language instructions.

Acronyms and aliases

compensation operation variant

Frequently asked questions

When is a compensating transaction needed?

It is needed when part of a multi-step workflow completed in an external system but later steps failed and ordinary rollback is unavailable.

Does compensation always restore the exact previous state?

No. It may create a new action that offsets the earlier effect while retaining an auditable history of both operations.

Videos explaining compensating transaction