Transactions
A database transaction is a sequence of operations performed as a single unit of work, which is atomic, consistent, isolated, and durable (ACID).
Two phase commit
The commit takes place as soon as all the systems involved agree. Otherwise, the whole transaction is rolled back. Preferred for short transactions or when only a few systems are involved.
Further information
Link: Two phase commit
SAGA Pattern
A compensating action is also defined for each action to be executed in the event of a rollback. It can be used for long-running (e.g. asynchronous) transactions. Does not require a global lock, scales very well, but requires significant effort.
There are two types:
- Choreography: Each service knows what to do next.
- Orchestration: Here there is a central controller that determines what to do next.
Further information
Link: Saga pattern