Compensating transaction
In transaction processing and distributed computing, a compensating transaction is a transaction that reverses the effects of a previously committed transaction.[src] It is a core concept in the saga design pattern, used to maintain data consistency across multiple services or databases in scenarios where traditional ACID transactions are not feasible or practical.[src] A compensating transaction is necessary when a business process, which may consist of several individual transactions, fails after one or more of its steps have already been successfully completed (committed).[src] Unlike a database rollback, which discards uncommitted changes, a compensating transaction is a new transaction that applies business logic to semantically undo the work of a completed transaction, thereby restoring the system to a consistent state.[src]
In transaction processing and distributed computing, a compensating transaction is a transaction that reverses the effects of a previously committed transaction.[src] It is a core concept in the saga design pattern, used to maintain data consistency across multiple services or databases in scenarios where traditional ACID transactions are not feasible or practical.[src] A compensating transaction is necessary when a business process, which may consist of several individual transactions, fails after one or more of its steps have already been successfully completed (committed).[src] Unlike a database rollback, which discards uncommitted changes, a compensating transaction is a new transaction that applies business logic to semantically undo the work of a completed transaction, thereby restoring the system to a consistent state.[src] ===Long-running transactions (Sagas)=== Compensating transactions are fundamental to the saga pattern.[src] A saga is a sequence of local transactions where each transaction updates data within a single service and publishes an event.[src] If a local transaction fails for any reason, the saga executes a series of compensating transactions to revert the changes made by the preceding local transactions.[src] This pattern is essential for processes that are long-lived, such as a trip-booking process that involves coordinating flights, hotels, and car rentals.[src] Because these operations might span a long period and involve multiple independent web services, holding database locks is impractical.[src] Instead, each service commits its transaction and has a compensating transaction ready in case a subsequent step fails.[src] This differs from distributed transactions using the two-phase-commit protocol, as it avoids locking resources for extended durations.[src] ==See also== ACID Business Process Execution Language (BPEL) Two-phase commit protocol ==References==[src]
16 sentences · 16 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Compensating transaction." encyclopegia.org, 2025, https://encyclopegia.org/wiki/compensating-transaction. Accessed 04 December 2026.
Chicago
"Compensating transaction." encyclopegia.org. Accessed December 4, 2026. https://encyclopegia.org/wiki/compensating-transaction.
APA
encyclopegia.org. (2025). Compensating transaction. Retrieved December 4, 2026, from https://encyclopegia.org/wiki/compensating-transaction
Accessed December 4, 2026 · CC BY-SA 4.0 · citation page · JSON