The Two-Phase Commit is fairly standard for synchronous processing in order to avoid inconsistent state in a distributed environment.
1) User wants to Update; 2) Prepare; 3) Write to Log; 4) Ready; 5) Commit
First the User wants to Update, then the update is prepared, written to log, set to a ready state, and finally committed to the database.
- Coordinator Sends “Prepare to Commit”
- Subordinates make sure they can do so no matter what
- Write the action to a log to tolerate failure
- Subordinates Reply “Ready to Commit”
- If all subordinates ready, send “Commit”
- If anyone failed, send “Abort”