Two phase Commit Protocol
In
transaction processing, databases,
and computer networking,
the two-phase commit
protocol (2PC)
is a type
of atomic commitment
protocol (ACP).
Commit
request phase or voting
phase
The
coordinator sends a
query to commit
message to all
cohorts and waits
until it has
received a reply from
all cohorts.
The
cohorts execute the
transaction up to
the point where
they will be
asked to commit.
Then each write an
entry to their
undo log and
an entry to
their redo log. Each
cohort replies with
an agreement message
(cohort votes Yes to commit),
if the cohort's
actions succeeded,
or an abort
message (cohort votes
No, not to
commit), if the
cohort experiences
a failure that
will make it
impossible to commit. Commit phase or
Completion phase then Success.
If
the coordinator received
an agreement message
from all cohorts
during the commit-request phase:
The
coordinator sends a
commit message to
all the cohorts.
Each
cohort completes the
operation, and releases
all the locks
and resources held
during the transaction.Each cohort
sends an acknowledgment to the coordinator.
The
coordinator completes the
transaction when all
acknowledgments have been
received.
Failure If any
cohort votes No
during the commit-request phase
(or the coordinator's
timeout expires):
The
coordinator sends a
rollback message to
all the cohorts.
Each
cohort undoes the
transaction using the
undo log, and
releases the resources
and locks
held
during the transaction.
Each cohort
sends an acknowledgement to
the coordinator.
The coordinator
undoes the transaction
when all acknowledgements have
been received.
Comments
Post a Comment