Two phase commit protocol includes 2 phase:
- Prepare phase : Transaction coordinator will ask every RM whether it prepared to commit transaction. All transaction participants are ready to commit the transaction, the transaction coordinator will issue the commit command.
- Commit phase : Transaction participants will commit the transaction after receiving the commit command and return a message indicating whether the commit was successful or failed.
I have a few questions about the commit phase:
After receiving the commit command, all transaction participants will commit the transaction. If a participant fails to commit and tells the coordinator, coordinator will send the abort command to make other participants rollback.
If other participants successfully committed when they received the rollback command, how to ensure data consistency among all transaction participants?
- If other successfully committed participants will rollback, how is the rollback performed? Isn’t it said that transactions cannot be rolled back after they are committed?
- Or the participant which failed to commit will retry committing?
- How do existing distributed transaction frameworks handle such situations?
I can’t find an answer online that can solve this question
user26724571 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.