Two Phase Commit
A pattern to implement distributed transaction. Which involves 2 phase
- Prepare phase:
- Coordinator asks the participants to whether or not they're ready to commit.
- They return
yes
orno
- Commit phase:
- If all the participants say
yes
, we commit - If one participants say
no
, we ask all the participants to rollback
- If all the participants say
What happen if our services keep failing?
We can store the status in the coordinator of the failing task and investigate.
Applications
- Cross multiple database commits
- Simple and fast service