2- PHASE COMMIT PROTOCOL
A distributed database is a database in which storage devices are not all attached to a common CPU. It may be stored in multiple computers located in the same physical location, or may be dispersed over a network of interconnected computers. Collections of data (e.g. in a database) can be distributed across multiple physical locations.
2 Phase Commit Protocol
1. Provides automatic recovery in case system of media failure occurs
during execution of the transaction.
2. 2 Phase commit protocol ensures that all participating database server
receive and implement the same action (either to commit or rollback a
transaction),regardless of local or network failure.)
3. Two-phase commit is a standard protocol in distributed transactions for
achieving ACID properties.
4. A database server automatically uses the two-phase commit protocol for
any transaction that modifies data on multiple database servers.
5. In this protocol one node is designated the coordinator which is the
Phase of two phase commit protocol
In this protocol the coordinator sends all the data modification instruction to
all the participants.
Then the coordinator starts two phase commit protocol.
This protocol has two parts.
1) Precommit phase
Coordinator : directs each participant database server to prepare to commit the transaction.
Participants: every participant notifies the coordinator whether it can commit its transaction .
2) Postdecision phase
Coordinator: the coordinator writes the commit record or rollback record to the coordinator’s logical log and then directs each participant database server to either commit or roll back the transaction.
Participants : If the coordinator issues a commit the transaction by writing the commit record to to the logical log and then sending a message to the coordinator acknowledging that the transaction was committed.