Two-Phase Commit
It is the second type of commit protocol in DBMS. It was introduced to reduce the vulnerabilities of the one phase commit protocol. There are two phases in the two-phase commit protocol.
Prepare Phase
Each slave sends a ‘DONE’ message to the controlling site after each slave has completed its transaction.
After getting ‘DONE’ message from all the slaves, it sends a “prepare” message to all the slaves.
Then the slaves share their vote or opinion whether they want to commit or not. If a slave wants to commit, it sends a message which is “Ready”.
If the slaves doesn’t want to commit, it then sends a “Not Ready” message.
Commit/Abort Phase
Controlling Site, after receiving “Ready” message from all the slaves
- The controlling site sends a message “Global Commit” to all the slaves. The message contains the details of the transaction which needs to be stored in the databases.
- Then each slave completes the transaction and returns an acknowledgement message back to the controlling site.
- The controlling site after receiving acknowledgement from all the slaves, which means the transaction is completed.
When the controlling site receives “Not Ready” message from the slaves
- The controlling site sends a message “Global Abort” to all the slaves.
- After receiving the “Global Abort” message, the transaction is aborted by the slaves. Then the slaves sends back an acknowledegement message back to the controlling site.
- When the controlling site receives Abort Acknowledgement from all the slaves, it means the transaction is aborted.
Commit Protocol in DBMS
This article covers topics related to the database management system. In this article, we will learn about the commit protocols that are in the subject of database management systems. This article then describes the types of Commit protocols in database management systems. It then talks about the advantages of a Database Management System.
Contact Us