DDB.NOTES
DDB.NOTES
Commit protocols are crucial in distributed database systems to ensure atomicity across multiple
sites. When a transaction is executed at multiple sites, it must either be committed at all the sites
or aborted at all the sites. Here are some commonly used commit protocols:
1. **One-Phase Commit**: This is the simplest commit protocol. In this protocol, there is a
controlling site and a variety of slave sites where the transaction is performed. The steps followed
in the one-phase commit protocol are: .
- Each slave sends a 'DONE' message to the controlling site after each slave has completed its
transaction. .
- After sending the 'DONE' message, the slaves start waiting for a 'Commit' or 'Abort' response
from the controlling site. .
- After receiving the 'DONE' message from all the slaves, then the controlling site decides whether
they have to commit or abort. .
- Then it sends a message to every slave. Then after the slave performs the operation as instructed
by the controlling site, they send an acknowledgement to the controlling site.
2. **Two-Phase Commit**: This protocol 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.
3. **Three-Phase Commit**: This protocol was proposed to overcome the blocking problem of the
two-phase commit protocol. It is an extension of the two-phase commit protocol and includes an
extra phase called pre-commit, which makes this protocol non-blocking.