Docsity

Two-Phase Commit Protocol Solutions and Optimizations, Exercises of Transaction Processing for E Commerce

Partial preview of the text

Download Two-Phase Commit Protocol Solutions and Optimizations and more Exercises Transaction Processing for E Commerce in PDF only on Docsity!

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 P

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 P

1.C C is blocked.

This cannot happen. The coordinator can always unilaterally abort an undecided tx.

C

P1 P

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- 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.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.