Home |
Previous Page | Next Page Distributed Data > Multiphase Commit Protocols > Two-Phase Commit Protocol >
In a two-phase commit transaction,
the coordinator sends all the data modification instructions (for example,
inserts) to all the participants. Then, the coordinator starts the two-phase
commit protocol. The two-phase commit protocol has two parts, the precommit phase and the postdecision phase.
Precommit Phase
During the precommit phase, the coordinator and participants perform the
following dialog:
- Coordinator. The coordinator directs each participant database server
to prepare to commit the transaction.
- Participants. Every participant notifies the coordinator
whether it can commit its transaction branch.
- Coordinator. The coordinator, based on the response
from each participant, decides whether to commit or roll back the transaction.
It decides to commit only if all participants indicate
that they can commit their transaction branches. If any participant indicates
that it is not ready to commit its transaction branch
(or if it does not respond), the coordinator decides to end the global transaction.
Postdecision Phase
During the postdecision phase, the coordinator and
participants perform the following dialog:
- 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 issued a commit
message, the participants commit the transaction by writing the commit record
to the logical log and then sending a message to the coordinator acknowledging
that the transaction was committed. If the coordinator issued a rollback message,
the participants roll back the transaction but do not send an acknowledgment
to the coordinator.
- Coordinator: If the coordinator issued a message
to commit the transaction, it waits to receive acknowledgment from each participant
before it ends the global transaction. If the coordinator issued a message
to roll back the transaction, it does not wait for acknowledgments from the
participants.
Home |
[ Top of Page | Previous Page | Next Page | Contents |
Index ]