The document discusses the two-phase commit (2PC) protocol used in transaction processing to ensure synchronized transactions across multiple databases. It outlines the phases involved in the protocol, including the prepare phase and the commit/abort phase, as well as the disadvantages of the protocol, such as its blocking nature. Additionally, it touches on Sinfonia, a system addressing the challenges of 2PC in real systems to improve consistency and reduce development efforts.
Describe the Twophase commit I believe most of people know what 2PC (two-phase commit protocol) is and how to use it in Java or most of modern languages. Basically, it is used to make sure the transactions are in sync when you have 2 or more DBs. Assume I've two DBs (A and B) using 2PC in two different locations. Before A and B are ready to commit a transaction, both DBs will report back to the transaction manager saying they are ready to commit. So, when the transaction manager is acknowledged, it will send a signal back toA and B telling them to go ahead.
5.
How to worktwo phase commit The steps performed in the two phases are as follows .... Phase 1: Prepare Phase After each slave has locally completed its transaction, it sends a “DONE” message to the controlling site. When the controlling site has received “DONE” message from all slaves, it sends a “Prepare” message to the slaves. The slaves vote on whether they still want to commit or not. If a slave wants to commit, it sends a “Ready” message. A slave that does not want to commit sends a “Not Ready” message. This may happen when the slave has conflicting concurrent transactions or there is a timeout.
6.
Phase 2: Commit/AbortPhase After the controlling site has received “Ready” message from all the slaves − The controlling site sends a “Global Commit” message to the slaves. The slaves apply the transaction and send a “Commit ACK” message to the controlling site. When the controlling site receives “Commit ACK” message from all the slaves, it considers the transaction as committed. After the controlling site has received the first “Not Ready” message from any slave − The controlling site sends a “Global Abort” message to the slaves. The slaves abort the transaction and send a “Abort ACK” message to the controlling site. When the controlling site receives “Abort ACK” message from all the slaves, it considers the transaction as aborted.
7.
The greatest disadvantageof the two-phase commit protocol is that it is a blocking protocol. If the coordinator fails permanently, some cohorts will never resolve their transactions:After a cohort has sent an agreement message to the coordinator, it will block until a commit or rollback is received. Two phase commit Disadvantages
8.
Example Clients want all-or-nothingtransactions Transfer either happens or not at all Bank A Bank B Transfer $1000 From A:$3000 To B:$2000 client
9.
Strawman solution Bank ABank B Transfer $1000 From A:$3000 To B:$2000 client Transaction coordinator
10.
Failures in adistributed system Consistency requires agreement among multiple servers Is transaction X committed? Have all servers applied update X to a replica? Achieving agreement w/ failures is hard Impossible to distinguish host vs. network failures This class: all-or-nothing atomicity in distributed systems
Handling timeout onA/B TC times out waiting for A (or B)’s “yes/no” response Can TC unilaterally decide to commit? Can TC unilaterally decide to abort?
What problem isSinfonia addressing? Targeted uses systems or infrastructural apps within a data center Sinfonia: a shared data service Span multiple nodes Replicated with consistency guarantees Goal: reduce development efforts for system programmers
15.
Sinfonia uses 2Pcommit prepare commit action1 action2 actions… Traditional transactions: general but expensive BEGIN tx If (a > 0 && b== 0) b = a * a for (i = 0; i < a; i++) b += i END tx Mini-transaction: less general but efficient BEGIN tx If (a == 3000 && b==2000) { a=2000 b=3000 } END tx Prepare & exec commit Traditional transactions Mini- transactions coordinator coordinator