Compensating transaction
From Wikipedia, the free encyclopedia
When processing data it is an useful abstraction to split the processing in transactions: where each transaction may consists of several individual operations, but must move the system data among consistent states. In the context of a database this is easily achieved using transactions and the commit
/rollback
mechanism.
For systems where there isn't any commit
/rollback
mechanism available one can undo a failed transaction with a Compensating Transaction, which will bring the system back to its initial state. It is just a workaround which has to be implemented manually and cannot guarantee that the system always ends in a consistent state. What if the Compensating Transaction also fails? Depending on the situation (regulation, criticality, development team skills, budget...) an implementation will strive to achieve more or less reliability. A minimal requirement in case of failure is to expose the fact in some way: logging, email, ...