SlideShare a Scribd company logo
Assignment 5 - Solution
Problem 1
Consider a system that uses the two-phase commit protocol with
the cooperative termination protocol and no other optimizations.
Assuming there are two participants (P1 and P2) and a
coordinator (C), for each of the following either describe an
execution scenario or explain why it cannot happen:
C
P1 P2
1.A P1 and P2 are blocked.
C sends “prepare-to-commit”
P1 & P2 send “yes-prepared”
C crashes, which leaves P1 and P2 blocked.
C
P1 P2
1.B. Only P2 is blocked.
1. C sends “prepare-to-commit”
2. P1 & P2 send “yes-prepared”
3. Communication failure at P2
• P1 and C terminate the protocol
• P1 and C crash
• P2 is blocked
1. C sends “prepare-to-commit”
2. P1 & P2 send “yes-prepared”
3. P2 crashes
• P1 and C terminate the protocol
• P1 and C crash
• P2 is recovers and is blocked
1.C C is blocked.
This cannot happen.
The coordinator can always unilaterally abort an undecided tx.
C
P1 P2
Problem 2
Suppose there are n processes involved in 2PC, where process 1 is
the transaction’s home. Suppose the processes are arranged in a
chain (NOT a ring), so that each process can only communicate with
adjacent processes in the chain.
That is, process 1 can communicate only with process 2, process n-1
can communicate only with process n, and for each i where 1<i<n,
process i can communicate only with processes i-1 and i+1.
1 i-1 i i+1 N
2.A Devise a version of the 2PC protocol for this arrangement
of processes that uses 2n – 2 messages to commit a
transaction.
Process 1
Starts the commit activity.
Prepares, then sends a Request-to-Prepare to Process 2.
Process 2
Prepares, then sends a Request-to-Prepare to 3.
…
Process n
Receives a request to prepare
It commits
Sends a Commit message to n-1.
2.b. In the protocol you devised in (a), is there any process
that is never in an uncertainty period?
Yes, Process n.
2.C In the protocol you devised in (a), what action commits
the transaction?
The log write of a commit record at process n effectively
commits the transaction.
2.D Explain how to modify the protocol to speed up the
protocol in the event that a process votes No.
A process that votes No
should send Abort to its two neighbors (if present),
including lower and higher numbered processes.
The lower-numbered neighbor should propagate the abort back
toward process 1.
The higher-numbered neighbor should propagate the abort up
toward process n.

More Related Content

PDF
Assignment.5.2012
PPTX
More Mining
PPTX
Mining
PDF
Distributed Computing On Topics of: Leader election + Byzantine algorithms)
PDF
Distributed Computing Set 3 - Topics of non-Byzantine Consensus
PPTX
The paxos commit algorithm
PPT
PPTX
4G MOBILE COMMUNICATION SYSTEM
Assignment.5.2012
More Mining
Mining
Distributed Computing On Topics of: Leader election + Byzantine algorithms)
Distributed Computing Set 3 - Topics of non-Byzantine Consensus
The paxos commit algorithm
4G MOBILE COMMUNICATION SYSTEM

Viewers also liked (12)

PPT
10a log
DOCX
PDF
MarkH-CV 2015
PDF
Transactions
PPT
Dynamic Power of QFT - Copy
PPT
15 bufferand records
PDF
21 domino mohan-1
PPT
03 fault model
PDF
Assignment1.2012
PPT
05 tp mon_orbs
DOCX
UPDATED INTERVIEW GUIDE
PDF
Emerging Trends and Tech
10a log
MarkH-CV 2015
Transactions
Dynamic Power of QFT - Copy
15 bufferand records
21 domino mohan-1
03 fault model
Assignment1.2012
05 tp mon_orbs
UPDATED INTERVIEW GUIDE
Emerging Trends and Tech
Ad

Similar to Solution5.2012 (20)

PDF
6 two phasecommit
PPT
운영체제론 Ch16
PPT
Ch17 OS
 
PPT
PPTX
mutual exclusion algos 16619.4 pptx cloud computing
PPT
Chapter 18 - Distributed Coordination
PPTX
operating system notes about deadlock 3.pptx
PPTX
Dos.pptx
PPT
Lecture16-17.ppt
PDF
Solution7.2012
PPTX
Chapter6 Synchronization in Operating systems.pptx
DOCX
Critical section operating system
PDF
Process Synchronization
PDF
Process Synchronization
PPT
Operating Systems - "Chapter 5 Process Synchronization"
PPTX
Process synchronization in operating system
PPTX
An optimal algorithm for mutual exclusion in computer networks
PPTX
Lecture 5 inter process communication
6 two phasecommit
운영체제론 Ch16
Ch17 OS
 
mutual exclusion algos 16619.4 pptx cloud computing
Chapter 18 - Distributed Coordination
operating system notes about deadlock 3.pptx
Dos.pptx
Lecture16-17.ppt
Solution7.2012
Chapter6 Synchronization in Operating systems.pptx
Critical section operating system
Process Synchronization
Process Synchronization
Operating Systems - "Chapter 5 Process Synchronization"
Process synchronization in operating system
An optimal algorithm for mutual exclusion in computer networks
Lecture 5 inter process communication
Ad

More from ashish61_scs (20)

PDF
7 concurrency controltwo
PPT
22 levine
PPT
20 access paths
PPT
19 structured files
PPT
18 philbe replication stanford99
PDF
17 wics99 harkey
PPT
16 greg hope_com_wics
PPT
14 turing wics
PPT
14 scaleabilty wics
PPT
13 tm adv
PPT
PPT
10b rm
PPT
09 workflow
PPT
08 message and_queues_dieter_gawlick
PPT
06 07 lock
PPT
04 transaction models
PPT
02 fault tolerance
PPT
01 whirlwind tour
PDF
Solution6.2012
PDF
Solution8 v2
7 concurrency controltwo
22 levine
20 access paths
19 structured files
18 philbe replication stanford99
17 wics99 harkey
16 greg hope_com_wics
14 turing wics
14 scaleabilty wics
13 tm adv
10b rm
09 workflow
08 message and_queues_dieter_gawlick
06 07 lock
04 transaction models
02 fault tolerance
01 whirlwind tour
Solution6.2012
Solution8 v2

Solution5.2012

  • 1. Assignment 5 - Solution Problem 1 Consider a system that uses the two-phase commit protocol with the cooperative termination protocol and no other optimizations. Assuming there are two participants (P1 and P2) and a coordinator (C), for each of the following either describe an execution scenario or explain why it cannot happen: C P1 P2
  • 2. 1.A P1 and P2 are blocked. C sends “prepare-to-commit” P1 & P2 send “yes-prepared” C crashes, which leaves P1 and P2 blocked. C P1 P2
  • 3. 1.B. Only P2 is blocked. 1. C sends “prepare-to-commit” 2. P1 & P2 send “yes-prepared” 3. Communication failure at P2 • P1 and C terminate the protocol • P1 and C crash • P2 is blocked 1. C sends “prepare-to-commit” 2. P1 & P2 send “yes-prepared” 3. P2 crashes • P1 and C terminate the protocol • P1 and C crash • P2 is recovers and is blocked
  • 4. 1.C C is blocked. This cannot happen. The coordinator can always unilaterally abort an undecided tx. C P1 P2
  • 5. Problem 2 Suppose there are n processes involved in 2PC, where process 1 is the transaction’s home. Suppose the processes are arranged in a chain (NOT a ring), so that each process can only communicate with adjacent processes in the chain. That is, process 1 can communicate only with process 2, process n-1 can communicate only with process n, and for each i where 1<i<n, process i can communicate only with processes i-1 and i+1. 1 i-1 i i+1 N
  • 6. 2.A Devise a version of the 2PC protocol for this arrangement of processes that uses 2n – 2 messages to commit a transaction. Process 1 Starts the commit activity. Prepares, then sends a Request-to-Prepare to Process 2. Process 2 Prepares, then sends a Request-to-Prepare to 3. … Process n Receives a request to prepare It commits Sends a Commit message to n-1.
  • 7. 2.b. In the protocol you devised in (a), is there any process that is never in an uncertainty period? Yes, Process n. 2.C In the protocol you devised in (a), what action commits the transaction? The log write of a commit record at process n effectively commits the transaction.
  • 8. 2.D Explain how to modify the protocol to speed up the protocol in the event that a process votes No. A process that votes No should send Abort to its two neighbors (if present), including lower and higher numbered processes. The lower-numbered neighbor should propagate the abort back toward process 1. The higher-numbered neighbor should propagate the abort up toward process n.