Reputation: 1930
In 2 Phase Commit, after all the component that participate in the transaction have voted "Yes" the Transaction Co-ordinateer issues the "Commit" command. And then each participants commits their own transaction.
What happens if any of the participants fail at the "Commit" step? While this component has failed, other might have already commited their transactions. Is the Transaction Coordinater able to issues a Rollback command to all the participants if this happens.
Thanks.
Upvotes: 1
Views: 292
Reputation: 2978
The whole purpose of the first phase is to ensure that nothing fails during the commit phase. At least due to data integrity or business process point of view. So if the prepare phase of the commit is fine then it can be assumed that commit will work, except network/communication failure.
All the participating system must agree on one or the other way of handling the situation
1.Auto-commit. If the rollback is not explicitly called by the coordinator,(within a given time) the transaction would be treated as committed by the respective participating system.
2.Transaction Coordinator retries for each failed component. In case of network failure the retry may still work.
3.Compensation. After a specified number of retries the transaction coordinator assumes that the transaction has ended in an inconsistent state. It can then try to compensate. ( note: this is not necessarily the roll back, this is like actions to be taken when a transaction fails).
Now think about this. Compensation itself may not be successful across all resource managers.
Some business processes may need manual compensation as well ! SO you need to log, raise alerts and a manual compensation may be needed to bring the system back to the original state.
Upvotes: 3