Transactions. Transactions. Distributed Software Systems. A client s banking transaction. Bank Operations. Operations in Coordinator interface

Similar documents
Distributed Transactions

EE324 INTRO. TO DISTRIBUTED SYSTEMS LECTURE 13 TRANSACTIONS

permanent. Otherwise (only one process refuses or crashs), the state before beginning the operations is reload.

Distributed Transactions Brian Nielsen

Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428. Fall 2012

(Pessimistic) Timestamp Ordering. Rules for read and write Operations. Read Operations and Timestamps. Write Operations and Timestamps

(Pessimistic) Timestamp Ordering

Figure 13.1 Transactions T and U with exclusive locks. Transaction T: Bank$Withdraw(A, 4) Bank$Deposit(B, 4)

Problem: if one process cannot perform its operation, it cannot notify the. Thus in practise better schemes are needed.

CSE 486/586 Distributed Systems

CSE 486/586 Distributed Systems

Control. CS432: Distributed Systems Spring 2017

Distributed Systems (ICE 601) Transactions & Concurrency Control - Part1

Fault Tolerance. Fall 2008 Jussi Kangasharju

Chapter 22. Transaction Management

Databases. Laboratorio de sistemas distribuidos. Universidad Politécnica de Madrid (UPM)

Synchronization Part 2. REK s adaptation of Claypool s adaptation oftanenbaum s Distributed Systems Chapter 5 and Silberschatz Chapter 17

Synchronization. Chapter 5

DISTRIBUTED SYSTEMS [COMP9243] Lecture 5: Synchronisation and Coordination (Part 2) TRANSACTION EXAMPLES TRANSACTIONS.

DISTRIBUTED SYSTEMS [COMP9243] Lecture 5: Synchronisation and Coordination (Part 2) TRANSACTION EXAMPLES TRANSACTIONS.

Transaction Management. Pearson Education Limited 1995, 2005

Synchronization Part II. CS403/534 Distributed Systems Erkay Savas Sabanci University

Transactions. ACID Properties of Transactions. Atomicity - all or nothing property - Fully performed or not at all

Synchronisation and Coordination (Part 2)

Some Examples of Conflicts. Transactional Concurrency Control. Serializable Schedules. Transactions: ACID Properties. Isolation and Serializability

Synchronization. Clock Synchronization

Banking Example (Once Again) CSE 486/586 Distributed Systems Concurrency Control Properties of Transactions: ACID. Transaction. Performance?

Middleware and Distributed Systems. Transactions. Martin v. Löwis

Transactions. A Banking Example

Fault Tolerance. o Basic Concepts o Process Resilience o Reliable Client-Server Communication o Reliable Group Communication. o Distributed Commit

Concurrency Control. Transaction Management. Lost Update Problem. Need for Concurrency Control. Concurrency control

A transaction is a sequence of one or more processing steps. It refers to database objects such as tables, views, joins and so forth.

CSE 486/586: Distributed Systems

Topics in Reliable Distributed Systems

Transactions. Kathleen Durant PhD Northeastern University CS3200 Lesson 9

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

CSE 444: Database Internals. Lectures Transactions

Concurrency Control in Distributed Systems. ECE 677 University of Arizona

Database Systems. Announcement

Transactions. Transaction. Execution of a user program in a DBMS.

Transaction Management

TRANSACTION PROPERTIES

DB2 Lecture 10 Concurrency Control

CHAPTER 3 RECOVERY & CONCURRENCY ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI

Chapter 15 : Concurrency Control

Atomic Transac1ons. Atomic Transactions. Q1: What if network fails before deposit? Q2: What if sequence is interrupted by another sequence?

Intro to Transactions

Distributed Transaction Management

Intro to Transaction Management

L i (A) = transaction T i acquires lock for element A. U i (A) = transaction T i releases lock for element A

Distributed File System

CprE Fault Tolerance. Dr. Yong Guan. Department of Electrical and Computer Engineering & Information Assurance Center Iowa State University

CONCURRENCY CONTROL, TRANSACTIONS, LOCKING, AND RECOVERY

TRANSACTION PROCESSING PROPERTIES OF A TRANSACTION TRANSACTION PROCESSING PROPERTIES OF A TRANSACTION 4/3/2014

Distributed Systems COMP 212. Revision 2 Othon Michail

Chapter 7 (Cont.) Transaction Management and Concurrency Control


Introduction to Data Management CSE 344

7 Fault Tolerant Distributed Transactions Commit protocols

Chapter 13 : Concurrency Control

Concurrency Control Algorithms

Consistency in Distributed Systems

Concurrency Control. R &G - Chapter 19

Databases - Transactions

Goal A Distributed Transaction

T ransaction Management 4/23/2018 1

CSE 530A ACID. Washington University Fall 2013

Advances in Data Management Transaction Management A.Poulovassilis

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 13 Managing Transactions and Concurrency

Overview. Introduction to Transaction Management ACID. Transactions

transaction - (another def) - the execution of a program that accesses or changes the contents of the database

Database Systems CSE 414

Transactions and Isolation

Information Systems (Informationssysteme)

Database Systems CSE 414

Today: Fault Tolerance. Reliable One-One Communication

Overview of Transaction Management

Lecture 21 Concurrency Control Part 1

CS5412: TRANSACTIONS (I)

Concurrency control CS 417. Distributed Systems CS 417

Transactions and Concurrency Control

Principles of Software Construction: Objects, Design, and Concurrency

Foundation of Database Transaction Processing. Copyright 2012 Pearson Education, Inc.

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

Graph-based protocols are an alternative to two-phase locking Impose a partial ordering on the set D = {d 1, d 2,..., d h } of all data items.

Concurrency Control & Recovery

Mobile and Heterogeneous databases Distributed Database System Transaction Management. A.R. Hurson Computer Science Missouri Science & Technology

Introduction to Data Management CSE 414

Exam 2 Review. Fall 2011

CSE 190D Database System Implementation

Page 1. Goals of Today s Lecture. The ACID properties of Transactions. Transactions

Distributed Transaction Management. Distributed Database System

Part III Transactions

CSE 444: Database Internals. Lectures 13 Transaction Schedules

Distributed Commit in Asynchronous Systems

TRANSACTION MANAGEMENT

CSE 344 MARCH 25 TH ISOLATION

Transcription:

ransactions ransactions Distributed Software Systems A transaction is a sequence of server operations that is guaranteed by the server to be atomic in the presence of multiple clients and server crashes. Free from interference by operations being performed on behalf of other concurrent clients Either all of the operations must be completed successfully or they must have no effect at all in the presence of server crashes Properties(ACID) Atomicity all or nothing Consistency a transaction must move the system from one consistent state to another Isolation intermediate effects must be invisible to other clients Durability Concepts: commit, abort ransactions 1 ransactions 2 Bank Operations Operations of the Account interface deposit(amount) deposit amount in the account withdraw(amount) withdraw amount from the account getbalance() -> amount return the balance of the account setbalance(amount) set the balance of the account to amount Operations of the Branch interface create(name) -> account create a new account with a given name lookp(name) -> account return a reference to the account with the given name branchotal() -> amount return the total of all the balances at the branch A client s banking transaction ransaction : a.withdraw(100); b.deposit(100); c.withdraw(200); b.deposit(200); ransactions 3 Operations in Coordinator interface openransaction() -> trans; starts a new transaction and delivers a unique ID trans. his identifier will be used in the other operations in the transaction. closeransaction(trans) -> (commit, abort); ends a transaction: a commit return value indicates that the transaction has committed; an abort return value indicates that it has aborted. abortransaction(trans); aborts the transaction. ransactions 4 1

ransaction life histories Concurrency control Successful Aborted by client Aborted by server openransaction openransaction openransaction operation operation operation operation operation operation server aborts transaction operation operation operation ERROR reported to client closeransaction abortransaction ransactions 5 Motivation: without concurrency control, we have lost updates, inconsistent retrievals, dirty reads, etc. (see following slides) Concurrency control schemes are designed to allow two or more transactions to be executed correctly while maintaining serial equivalence Serial Equivalence is correctness criterion Schedule produced by concurrency control scheme should be equivalent to a serial schedule in which transactions are executed one after the other Schemes: locking, optimistic concurrency control, time-stamp based concurrency control ransactions 6 Lost pdate Problem - 1 Consider the following transactions and with the initial account balances for a, b, and c as 100, 200, and 300 respectively. : balance = b.getbalance() b.setbalance(balance*1.1) a.withdrawn(balance/10) : balance = b.getbalance() b.setbalance(balance*1.1) c.withdrawn(balance/10) If we execute followed by, we get balances of 80, 242 and 278 600 If we execute followed by, we get balances of 78, 242 and 280 ransactions 7 Lost pdate Problem - 2 ransaction : balance = b.getbalance(); b.setbalance(balance*1.1); a.withdraw(balance/10) balance = b.getbalance(); $200 b.setbalance(balance*1.1); $220 a.withdraw(balance/10) $80 ransaction : balance = b.getbalance(); b.setbalance(balance*1.1); c.withdraw(balance/10) balance = b.getbalance(); $200 b.setbalance(balance*1.1); $220 c.withdraw(balance/10) $280 In the above, we get balances of 80, 220 and 280 s update of b was lost ransactions 8 2

Lost pdate Problem - 3 he inconsistent retrievals problem : balance = b.getbalance() b.setbalance(balance*1.1) a.withdrawn(balance/10) : balance = b.getbalance() b.setbalance(balance*1.1) c.withdrawn(balance/10) ransaction V a.withdraw(100) b.deposit(100) ransaction W: abranch.branchotal() balance = b.getbalance() b.setbalance(balance*1.1) a.withdrawn(balance/10) balance = b.getbalance() b.setbalance(balance*1.1) c.withdrawn(balance/10) a.withdraw(100); $100 b.deposit(100) $300 total = a.getbalance() $100 total = total+b.getbalance() $300 total = total+c.getbalance() We get balances of 80, 242 and 278, same as followed by ransactions 9 ransactions 10 A serially equivalent interleaving of V and W Serializability ransaction V: a.withdraw(100); b.deposit(100) ransaction W: abranch.branchotal() BEGIN_RANSACION x = 0; x = x + 1; END_RANSACION (a) BEGIN_RANSACION x = 0; x = x + 2; END_RANSACION (b) BEGIN_RANSACION x = 0; x = x + 3; END_RANSACION (c) a.withdraw(100); $100 b.deposit(100) $300 total = a.getbalance() $100 total = total+b.getbalance() $400 total = total+c.getbalance()... Schedule 1 Schedule 2 Schedule 3 x = 0; x = x + 1; x = 0; x = x + 2; x = 0; x = x + 3 x = 0; x = 0; x = x + 1; x = x + 2; x = 0; x = x + 3; x = 0; x = 0; x = x + 1; x = 0; x = x + 2; x = x + 3; (d) Legal Legal Illegal a) c) hree transactions 1, 2, and 3 d) Possible schedules ransactions 11 ransactions 12 3

Read and write operation conflict rules A non-serially equivalent interleaving of operations of transactions and Operations of different transactions Conflict Reason read read No Because the effect of a pair of read operations does not depend on the order in which they are executed read write Yes Because the effect of a read and a write operation depends on the order of their execution write write Yes Because the effect of a pair of write operations depends on the order of their execution ransaction : ransaction : x = read(i) write(i, 10) write(j, 20) y = read(j) write(j, 30) z = read (i) ransactions 13 ransactions 14 A dirty read when transaction aborts Nested transactions ransaction : a.getbalance() a.setbalance(balance + 10) balance = a.getbalance() $100 a.setbalance(balance + 10) $110 abort transaction ransaction : a.getbalance() a.setbalance(balance + 20) balance = a.getbalance() $110 a.setbalance(balance + 20) $130 commit transaction uses result of uncommitted transaction! ransactions 15 : top-level transaction 1 = opensubransaction 2 = opensubransaction 1 : 2 : opensubransaction opensubransaction 11 : 12 : prov. commit provisional commit prov. commit prov. commit 21 : opensubransaction opensubransaction 211 : prov. commit prov.commit commit abort ransactions 16 4

Committing Nested ransactions Concurrency Control A transaction may commit or abort only after its child transactions have completed When a sub-transaction completes, it makes an independent decision either to commit provisionally or to abort. Its decision to abort is final. When a parent aborts, all of its sub-transactions are aborted. When a sub-transaction aborts, the parent can decide whether to abort or not. If a top-level transaction commits, then all of the subtransactions that have provisionally committed can commit too, provided that non of their ancestors has aborted. ransactions 17 General organization of managers for handling transactions. ransactions 18 Schemes for Concurrency control Locking Server attempts to gain an exclusive lock that is about to be used by one of its operations in a transaction. Can use different lock types (read/write for example) wo-phase locking Optimistic concurrency control ime-stamp based concurrency control ransactions and with exclusive locks ransaction : balance = b.getbalance() b.setbalance(bal*1.1) a.withdraw(bal/10) ransaction : balance = b.getbalance() b.setbalance(bal*1.1) c.withdraw(bal/10) Operations Locks Operations Locks openransaction bal = b.getbalance() lock B b.setbalance(bal*1.1) openransaction a.withdraw(bal/10) lock A bal = b.getbalance() waits for s lock on B closeransaction unlock A, B lock B b.setbalance(bal*1.1) c.withdraw(bal/10) lock C closeransaction unlock B, C ransactions 19 ransactions 20 5

wo-phase Locking (1) Strict wo-phase Locking (2) Strict two-phase locking. In two-phase locking, a transaction is not allowed to acquire any new locks after it has released a lock ransactions 21 ransactions 22 se of locks in strict two-phase locking Lock compatibility 1. When an operation accesses an object within a transaction: (a) If the object is not already locked, it is locked and the operation proceeds. (b) If the object has a conflicting lock set by another transaction, the transaction must wait until it is unlocked. (c) If the object has a non-conflicting lock set by another transaction, the lock is shared and the operation proceeds. (d) If the object has already been locked in the same transaction, the lock will be promoted if necessary and the operation proceeds. (Where promotion is prevented by a conflicting lock, rule (b) is used.) 2. When a transaction is committed or aborted, the server unlocks all objects it locked for the transaction. ransactions 23 For one object Lock requested read write Lock already set none OK OK read OK wait write wait wait Operation Conflict rules: 1. If a transaction has already performed a read operation on a particular object, then a concurrent transaction must not write that object until commits or aborts 2. If a transaction has already performed a read operation on a particular object, then a concurrent transaction must not read or write that object until commits or aborts ransactions 24 6

Deadlock with write locks he wait-for graph ransaction ransaction Operations Locks Operations Locks Waits for a.deposit(100); b.withdraw(100) write lock A b.deposit(200) write lock B waits for s a.withdraw(200); waits for s lock on B lock on A Waits for A B ransactions 25 ransactions 26 A cycle in a wait-for graph Another wait-for graph V W V W C V B Waits for ransactions 27 ransactions 28 7

Dealing with Deadlock in two-phase locking Deadlock prevention Acquire all needed locks in a single atomic operation Acquire locks in a particular order Deadlock detection Keep graph of locks held. Check for cycles periodically or each time an edge is added Cycles can be eliminated by aborting transactions imeouts Aborting transactions when time expires Resolution of deadlock ransaction ransaction Operations Locks Operations Locks a.deposit(100); b.withdraw(100) write lock A b.deposit(200) write lock B waits for s a.withdraw(200); waits for s lock on B (timeout elapses) s lock on A becomes vulnerable, unlock A, abort a.withdraw(200); lock on A write locks A unlock A, B ransactions 29 ransactions 30 Optimistic Concurrency Control Drawbacks of locking Overhead of lock maintenance Deadlocks Reduced concurrency Optimistic Concurrency Control In most applications, likelihood of conflicting accesses by concurrent transactions is low ransactions proceed as though there are no conflicts Optimistic Concurrency Control hree phases: Working Phase transactions read and write private copies of objects (most recently committed) Validation Phase Once transaction is done, the transaction is validated to establish whether or not its operations on objects conflict with operations of other transactions on the same object. If not conflict, can commit; else some form of conflict resolution is needed and the transaction may abort. pdate Phase if commit, private copies are used to make permanent change. ransactions 31 ransactions 32 8

Validation of transactions Optimistic Concurrency Control: Serializability of transaction v with respect to transaction i Working Validation pdate v and i are overlapping transactions 1 2 Earlier committed transactions For v to be serializable wrt i the following rules must hold v i Rule ransaction being validated 3 v write read 1. i must not read objects written by v read write 2. v must not read objects written by i active 1 write write 3. i must not write objects written by v and Later active transactions active 2 v must not write objects written by i If simplification is made that only one transaction may be in its validation or write phases at one time, then third rule is always satisfied ransactions 33 ransactions 34 Validation of ransactions Validation of transactions Backward validation of transaction v boolean valid = true; for (int i = startn+1; i <= finishn; i ++){ if (read set of v intersects write set of i ) valid = false; 1 2 Working Validation pdate Earlier committed transactions 3 Forward validation of transaction v boolean valid = true; for (int id = active1; id <= activen; id ++){ if (write set of v intersects read set of id ) valid = false; ransaction being validated active 1 Later active transactions v active 2 ransactions 35 ransactions 36 9

Schemes for Concurrency control Locking Optimistic concurrency control ime-stamp based concurrency control Each timestamp is assigned a unique timestamp at the moment it starts In distributed transactions, Lamport s timestamps can be used Every data item has a timestamp Read timestamp = timestamp of transaction that last read the item Write timestamp = timestamp of transaction that most recently changed an item A request to write to an object is valid only if that object was last read and written by earlier (wrt timestamps) transactions. A request to read an object is valid only if that object was last written by an earlier transaction. ransactions 37 Distributed ransactions Motivation Provide distributed atomic operations at multiple servers that maintain shared data for clients Provide recoverability from server crashes Properties Atomicity, Consistency, Isolation, Durability (ACID) Concepts: commit, abort, distributed commit ransactions 38 Distributed ransactions Nested banking transaction (a) Flat transaction (b) Nested transactions Client X Y Z Client X 1 2 Y M 11 N 12 21 P 22 = openransaction opensubransaction a.withdraw(10); opensubransaction b.withdraw(20); opensubransaction c.deposit(10); opensubransaction d.deposit(20); closeransaction Client X 1 Y 2 Z 3 4 A B C D a.withdraw(10) b.withdraw(20) c. deposit(10) d.deposit(20) ransactions 39 ransactions 40 10

Concurrency Control for Distributed ransactions A distributed banking transaction General organization of managers for handling distributed transactions. openransaction closeransaction. join join participant A BranchX a.withdraw(4); participant Client b.withdraw(, 3); B b.withdraw(3); = openransaction a.withdraw(4); c.deposit(4); b.withdraw(3); d.deposit(3); closeransaction join Note: the coordinator is in one of the servers, e.g. BranchX BranchY participant C D BranchZ c.deposit(4); d.deposit(3); ransactions 41 ransactions 42 Concurrency Control for Distributed ransactions Locking Distributed deadlocks possible imestamp ordering Lamport time stamps for efficiency it is required that timestamps issued by coordinators be roughly synchronized Interleavings of transactions, V and W d.deposit(10) V W lock D b.deposit(10) lock B a.deposit(20) lock A at Y at X b.withdraw(30) wait at Y c.withdraw(20) wait at Z c.deposit(30) lock C at Z a.withdraw(20) wait at X ransactions 43 ransactions 44 11

Distributed deadlock Local and global wait-for graphs (a) (b) W Waits for W local wait-for graph local wait-for graph global deadlock detector C Z D A X V V Waits for V Held by X Y V Held by B Waits for Y ransactions 45 ransactions 46 Atomic Commit Protocols he atomicity of a transaction requires that when a distributed transaction comes to an end, either all of its operations are carried out or none of them One phase commit Coordinator tells all participants to commit If a participant cannot commit (say because of concurrency control), no way to inform coordinator wo phase commit (2PC) he two-phase commit protocol - 1 Phase 1 (voting phase): 1. he coordinator sends a cancommit? (VOE_REQES) request to each of the participants in the transaction. 2. When a participant receives a cancommit? request it replies with its vote Yes (VOE_COMMI) or No (VOE_ABOR) to the coordinator. Before voting Yes, it prepares to commit by saving objects in permanent storage. If the vote is No the participant aborts immediately. ransactions 47 ransactions 48 12

he two-phase commit protocol - 2 Communication in two-phase commit protocol Phase 2 (completion according to outcome of vote): 3. he coordinator collects the votes (including its own). (a) If there are no failures and all the votes are Yes the coordinator decides to commit the transaction and sends a docommit (GLOBAL_COMMI) request to each of the participants. (b) Otherwise the coordinator decides to abort the transaction and sends doabort (GLOBAL_ABOR) requests to all participants that voted Yes. 4. Participants that voted Yes are waiting for a docommit or doabort request from the coordinator. When a participant receives one of these messages it acts accordingly and in the case of commit, makes a havecommitted call as confirmation to the coordinator. Coordinator step status 1 prepared to commit (waiting for votes) 3 committed done cancommit? Yes docommit havecommitted Participant step status 2 4 prepared to commit (uncertain) committed ransactions 49 ransactions 50 Operations for two-phase commit protocol cancommit?(trans)-> Yes / No Call from coordinator to participant to ask whether it can commit a transaction. Participant replies with its vote. docommit(trans) Call from coordinator to participant to tell participant to commit its part of a transaction. doabort(trans) Call from coordinator to participant to tell participant to abort its part of a transaction. havecommitted(trans, participant) Call from participant to coordinator to confirm that it has committed the transaction. getdecision(trans) -> Yes / No Call from participant to coordinator to ask for the decision on a transaction after it has voted Yes but has still had no reply after some delay. sed to recover from server crash or delayed messages. ransactions 51 wo-phase Commit protocol - 3 actions by coordinator: while SAR _2PC to local log; multicast VOE_REQES to all participants; while not all votes have been collected { wait for any incoming vote; if timeout { write GLOBAL_ABOR to local log; multicast GLOBAL_ABOR to all participants; exit; record vote; if all participants sent VOE_COMMI and coordinator votes COMMI{ write GLOBAL_COMMI to local log; multicast GLOBAL_COMMI to all participants; else { write GLOBAL_ABOR to local log; multicast GLOBAL_ABOR to all participants; Outline of the steps taken by the coordinator in a two phase commit protocol ransactions 52 13

wo-phase Commit protocol - 4 Steps taken by participant process in 2PC. actions by participant: write INI to local log; wait for VOE_REQES from coordinator; if timeout { write VOE_ABOR to local log; exit; if participant votes COMMI { write VOE_COMMI to local log; send VOE_COMMI to coordinator; wait for DECISION from coordinator; if timeout { multicast DECISION_REQES to other participants; wait until DECISION is received; /* remain blocked */ write DECISION to local log; if DECISION == GLOBAL_COMMI write GLOBAL_COMMI to local log; else if DECISION == GLOBAL_ABOR write GLOBAL_ABOR to local log; else { write VOE_ABOR to local log; send VOE ABOR to coordinator; ransactions 53 wo-phase Commit protocol - 5 a) he finite state machine for the coordinator in 2PC. b) he finite state machine for a participant. If a failure occurs during a blocking state (red boxes), there needs to be a recovery mechanism. ransactions 54 wo Phase Commit Protocol - 6 Recovery Wait in Coordinator use a time-out mechanism to detect participant crashes. Send GLOBAL_ABOR Init in Participant Can also use a time-out and send VOE_ABOR Ready in Participant P abort is not an option (since already voted to COMMI and so coordinator might eventually send GLOBAL_COMMI). Can contact another participant Q and choose an action based on its state. State of Q COMMI ABOR INI READY Action by P ransition to COMMI ransition to ABOR Both P and Q transition to ABOR (Q sends VOE_ABOR) Contact more participants. If all participants are READY, must wait for coordinator to recover ransactions 55 wo-phase Commit protocol - 7 actions for handling decision requests: /* executed by separate thread */ while true { wait until any incoming DECISION_REQES is received; /* remain blocked */ read most recently recorded SAE from the local log; if SAE == GLOBAL_COMMI send GLOBAL_COMMI to requesting participant; else if SAE == INI or SAE == GLOBAL_ABOR send GLOBAL_ABOR to requesting participant; else skip; /* participant remains blocked */ Steps taken for handling incoming decision requests. ransactions 56 14

hree Phase Commit protocol - 1 hree-phase Commit protocol - 2 Problem with 2PC If coordinator crashes, participants cannot reach a decision, stay blocked until coordinator recovers hree Phase Commit3PC here is no single state from which it is possible to make a transition directly to either COMMI or ABOR states here is no state in which it is not possible to make a final decision, and from which a transition to COMMI can be made a) Finite state machine for the coordinator in 3PC b) Finite state machine for a participant ransactions 57 ransactions 58 hree Phase Commit Protocol - 3 Recovery Wait in Coordinator same Init in Participant same PreCommit in Coordinator Some participant has crashed but we know it wanted to commit. GLOBAL_COMMI the application knowing that once the participant recovers, it will commit. Ready or PreCommit in Participant P (i.e. P has voted to COMMI) State of Q PRECOMMI ABOR INI READY Action by P ransition to PRECOMMI. If all participants in PRECOMMI, can COMMI the transaction ransition to ABOR Both P (in READY) and Q transition to ABOR (Q sends VOE_ABOR) Contact more participants. If can contact a majority and they are in Ready, then ABOR the transaction. If the participants contacted in PreCommit it is safe to COMMI the transaction Note: if any participant is in state PRECOMMI, it is impossible for any other participant to be in any state other than READY or PRECOMMI. ransactions 59 15