Docsity

Two-Phase Commit Protocol and Enlisting in a Transaction, Slides of Fundamentals of E-Commerce

Partial preview of the text

Download Two-Phase Commit Protocol and Enlisting in a Transaction and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Enlisting in a Transaction

•^

When an Application in a transaction T first calls an RM, theRM must tell the TM it is part of T.

-^

Called enlisting or joining the transaction

Transaction Manager

Resource Manager

Application

  1. Enlist(T)
  2. Write(X, T)
  3. StartTransaction(returns Tranction ID)

Enlisting in a Transaction (cont’d)

•^

When an application A in a transaction T first calls anapplication B at another node, B must tell its local TM thatthe transaction has arrived. Transaction

Manager Communications

Manager

Application A

  1. Call(AP-B, T) 2. AddBranch(N, T)

Transaction

Manager

Communications

Application BManager

  1. StartBranch(N, T)
  2. Call(AP-B, T)
  3. Send Call(AP-B, T)

Node M

Node N

Handling Multiple Protocols

•^

Communication managers solve the problem of handlingmultiple 2PC protocols by providing^ –

a model for communication between address spaces

a wire protocol for two-phase commit

-^

But, expect restrictions on multi-protocol interoperation

•^

The RM only talks to the TM-RM interface. The multi-protocol problem is solved by the TM vendor.

Transaction Manager

Resource ManagerResource ManagerResource Manager

Application

RM ops Enlist and 2PC ops

TX XA

2PC ops

OtherTMs

Communication

Manager

Send/receive msg XA+

Docsity.com

Complete Walkthrough

Application:

Start-transCall DBMSCall remote appCommit

Application

Comm Mgr

DatabaseSystem

Txn Manager

Transaction

Manager CommManager

  1. Req-prepare9. Prepared10. Commit11. Done
  2. Start Tran4. Add-branch7. Commit
  3. Call DBMS
  4. Call
  5. Start-branch
  6. Enlist

DBMS

7.6 Three Phase Commit- The Idea

•^

3PC prevents blocking in the absence of communicationsfailures (unrealistic, but …). It can be made resilient tocommunications failures, but then it may block

-^

3PC is much more complex than 2PC, but only marginally improves reliability — prevents some blocking situations.

-^

3PC therefore is not used much in practice

-^

Main idea: becoming certain and deciding to commit areseparate steps.

-^

3PC ensures that if any operational process is uncertain,then no (failed or operational) process has committed.

-^

So, in the termination protocol, if the operational processesare all uncertain, they can decide to abort (avoids blocking).

Three Phase Commit- The Protocol

  1. (Begin phase 1) Coordinator C sends Request-to-prepare

to all participants

  1. Participants vote Prepared or No, just like 2PC.3. If C receives Prepared from all participants, then (begin

phase 2) it sends Pre-Commit to all participants.

  1. Participants wait for Abort or Pre-Commit.

Participant acknowledges Pre-commit.

  1. After C receives acks from all participants, or times out on

some of them, it (begin third phase) sends Commit to allparticipants (that are up)