CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Concurrency Control --- 3 Steve Ko Computer Sciences and Engineering University at Buffalo.

Slides:



Advertisements
Similar presentations
CS 542: Topics in Distributed Systems Transactions and Concurrency Control.
Advertisements

CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
CS542: Topics in Distributed Systems Distributed Transactions and Two Phase Commit Protocol.
Slides for Chapter 13: Distributed transactions
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Byzantine Fault Tolerance Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Transactions Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Replication Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
1 TRANSACTION & CONCURRENCY CONTROL Huỳnh Văn Quốc Phương Thái Thị Thu Thủy
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Concurrency Control Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Concurrency Control Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Concurrency Control Steve Ko Computer Sciences and Engineering University at Buffalo.
Persistent State Service 1 Distributed Object Transactions  Transaction principles  Concurrency control  The two-phase commit protocol  Services for.
1 More on Distributed Coordination. 2 Who’s in charge? Let’s have an Election. Many algorithms require a coordinator. What happens when the coordinator.
CS 425 / ECE 428 Distributed Systems Fall 2014 Indranil Gupta (Indy) Lecture 18: Replication Control All slides © IG.
Distributed Systems Fall 2009 Distributed transactions.
Distributed Commit Dr. Yingwu Zhu. Failures in a distributed system Consistency requires agreement among multiple servers – Is transaction X committed?
CS162 Section Lecture 10 Slides based from Lecture and
Distributed Transactions March 15, Transactions What is a Distributed Transaction?  A transaction that involves more than one server  Network.
DISTRIBUTED SYSTEMS II AGREEMENT (2-3 PHASE COM.) Prof Philippas Tsigas Distributed Computing and Systems Research Group.
Lecture 16-1 Computer Science 425 Distributed Systems CS 425 / ECE 428 Fall 2013 Indranil Gupta (Indy) October 17, 2013 Lecture 16 Concurrency Control.
Distributed Systems CS 425 / CSE 424 / ECE 428 Transactions & Concurrency Control  2010, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi,
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Replication with View Synchronous Group Communication Steve Ko Computer Sciences and Engineering.
Lecture 12: Distributed transactions Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
CSE 486/586 CSE 486/586 Distributed Systems Concurrency Control Steve Ko Computer Sciences and Engineering University at Buffalo.
Distributed Transactions CS425 /CSE424/ECE428 – Distributed Systems – Fall 2011 Nikita Borisov - UIUC Material derived from slides by I. Gupta, M. Harandi,
Transactions and Concurrency Control Distribuerade Informationssystem, 1DT060, HT 2013 Adapted from, Copyright, Frederik Hermans.
DISTRIBUTED SYSTEMS II FAULT-TOLERANT AGREEMENT II Prof Philippas Tsigas Distributed Computing and Systems Research Group.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Replication Steve Ko Computer Sciences and Engineering University at Buffalo.
Distributed Transactions Chapter – Vidya Satyanarayanan.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion & Leader Election Steve Ko Computer Sciences and Engineering University.
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 17: Distributed.
 2002 M. T. Harandi and J. Hou (modified: I. Gupta) Distributed Transactions.
IM NTU Distributed Information Systems 2004 Distributed Transactions -- 1 Distributed Transactions Yih-Kuen Tsay Dept. of Information Management National.
A client transaction becomes distributed if it invokes operations in several different Servers There are two different ways that distributed transactions.
CSE 486/586 Distributed Systems Consistency --- 3
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Replication Steve Ko Computer Sciences and Engineering University at Buffalo.
TRANSACTION & CONCURRENCY CONTROL 1. CONTENT 2  Transactions & Nested transactions  Methods for concurrency control  Locks  Optimistic concurrency.
CSE 486/586 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Transactions on Replicated Data Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Paxos Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586 CSE 486/586 Distributed Systems Leader Election Steve Ko Computer Sciences and Engineering University at Buffalo.
Distributed Transactions What is a transaction? (A sequence of server operations that must be carried out atomically ) ACID properties - what are these.
10-Jun-16COMP28112 Lecture 131 Distributed Transactions.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Paxos Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586 CSE 486/586 Distributed Systems Concurrency Control Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586 Distributed Systems Consistency --- 1
Outline Announcements Fault Tolerance.
CSE 486/586 Distributed Systems Concurrency Control --- 1
CSE 486/586 Distributed Systems Consistency --- 1
CSE 486/586 Distributed Systems Concurrency Control --- 2
CSE 486/586 Distributed Systems Concurrency Control --- 3
Slides for Chapter 14: Distributed transactions
Distributed Transactions
Lecture 21: Replication Control
Distributed Transactions
Distributed Transactions
UNIVERSITAS GUNADARMA
Distributed Transactions
Distributed Transactions
TRANSACTION & CONCURRENCY CONTROL
CSE 486/586 Distributed Systems Concurrency Control --- 2
CSE 486/586 Distributed Systems Concurrency Control --- 1
Lecture 21: Replication Control
CSE 486/586 Distributed Systems Concurrency Control --- 3
Presentation transcript:

CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Concurrency Control Steve Ko Computer Sciences and Engineering University at Buffalo

CSE 486/586, Spring 2013 Recap Strict execution of transactions? –Delay both their read and write operations on an object until all transactions that previously wrote that object have either committed or aborted Two phase locking? –Growing phase –Shrinking phase Strict two phase locking? –Release locks only at either commit() or abort() 2

CSE 486/586, Spring 2013 Can We Do Better? What we saw was “exclusive” locks. Non-exclusive locks: break a lock into a read lock and a write lock Allows more concurrency –Read locks can be shared (no harm to share) –Write locks should be exclusive 3

CSE 486/586, Spring 2013 Non-Exclusive Locks non-exclusive lock compatibility Lock alreadyLock requested setreadwrite none OK OK read OKWAIT writeWAITWAIT A read lock is promoted to a write lock when the transaction needs write access to the same object. A read lock shared with other transactions’ read lock(s) cannot be promoted. Transaction waits for other read locks to be released. Cannot demote a write lock to read lock during transaction – violates the 2P principle 4

CSE 486/586, Spring 2013 Example: Non-Exclusive Locks Transaction T1 Transaction T2 OpenTransaction() balance = b.getBalance() OpenTransaction() balance = b.getBalance() b.setBalance =balance*1.1 Commit 5 R-Lock B … Cannot Promote lock on B, Wait Promote lock on B

CSE 486/586, Spring PL: a Problem What happens in the example below? Transaction T1 Transaction T2 OpenTransaction() balance = b.getBalance() OpenTransaction() balance = b.getBalance() b.setBalance =balance*1.1 6 R-Lock B … Cannot Promote lock on B, Wait …

CSE 486/586, Spring 2013 Deadlock Conditions Necessary conditions –Non-sharable resources (locked objects) –No lock preemption –Hold & wait or circular wait 7 T U Wait for Held by Wait for A B T U Held by Wait for A B V W... Wait for Held by Hold & Wait Circular Wait

CSE 486/586, Spring 2013 Preventing Deadlocks Acquiring all locks at once Acquiring locks in a predefined order Not always practical: –Transactions might not know which locks they will need in the future One strategy: timeout –If we design each transaction to be short and fast, then we can abort() after some period of time. 8

CSE 486/586, Spring 2013 Extracting Even More Concurrency Allow writing tentative versions of objects –Letting other transactions read from the previously committed version Allow read and write locks to be set together by different transactions –Unlike non-exclusive locks Read operations wait only if another transaction is committing the same object Disallow commit if other uncompleted transactions have read the objects –These transactions must wait until the reading transactions have committed This allows for more concurrency than read-write locks –Writing transactions risk waiting or rejection when commit 9

CSE 486/586, Spring 2013 Two-Version Locking Three types of locks: read lock, write lock, commit lock –Transaction cannot get a read or write lock if there is a commit lock When the transaction coordinator receives a request to commit –Converts all that transaction’s write locks into commit locks –If any objects have outstanding read locks, transaction must wait until the transactions that set these locks have completed and locks are released Compare with read/write locks: –Read operations are delayed only while transactions are committed –Read operations of one transaction can cause a delay in the committing of other transactions 10

CSE 486/586, Spring 2013 Two-Version Locking lock compatibility Lock alreadyLock requested setread writecommit none OK OK OK read OK OKWAIT write OK WAIT commitWAIT WAIT 11

CSE 486/586, Spring 2013 CSE 486/586 Administrivia PA3 deadline: 3/29 (Friday) PA2 grading –Will be done sometime next week (we wanted to grade the midterm first.) Anonymous feedback form still available. Please come talk to me! 12

CSE 486/586, Spring 2013 Distributed Transactions Transactions that invoke operations at multiple servers 13 T A Y Z B C D T T1T1 T2T2 T11 T12 T21 T22 A B C D F H K Flat Distributed Transaction Nested Distributed Transaction X

CSE 486/586, Spring 2013 Coordinator and Participants Coordinator –In charge of begin, commit, and abort Participants –Server processes that handle local operations 14 T A Y Z B C D X join Coordinator Participant Coordinator & Participants

CSE 486/586, Spring 2013 Example of Distributed Transactions 15.. BranchZ BranchX participant C D Client BranchY B A participant join T a.withdraw(4); c.deposit(4); b.withdraw(3); d.deposit(3); openTransaction b.withdraw(T, 3); closeTransaction T =openTransaction a.withdraw(4); c.deposit(4); b.withdraw(3); d.deposit(3); closeTransaction Note: the coordinator is in one of the servers, e.g. BranchX

CSE 486/586, Spring 2013 Atomic Commit Problem Atomicity principle requires that either all the distributed operations of a transaction complete, or all abort. At some stage, client executes closeTransaction(). Now, atomicity requires that either all participants (remember these are on the server side) and the coordinator commit or all abort. What problem statement is this? Consensus Failure model Arbitrary message delay & loss Crash-recovery with persistent storage 16

CSE 486/586, Spring 2013 Atomic Commit We need to ensure safety in real-life implementation. Never have some agreeing to commit, and others agreeing to abort. First cut: one-phase commit protocol. The coordinator communicates either commit or abort, to all participants until all acknowledge. What can go wrong? Doesn’t work when a participant crashes before receiving this message. Does not allow participant to abort the transaction, e.g., under deadlock. 17

CSE 486/586, Spring 2013 Two-Phase Commit First phase Coordinator collects a vote (commit or abort) from each participant (which stores partial results in permanent storage before voting). Second phase If all participants want to commit and no one has crashed, coordinator multicasts commit message If any participant has crashed or aborted, coordinator multicasts abort message to all participants 18

CSE 486/586, Spring 2013 Two-Phase Commit Communication 19 canCommit? Yes doCommit haveCommitted Coordinator 1 3 (waiting for votes) committed done prepared to commit step Participant 2 4 (uncertain) prepared to commit committed statusstepstatus

CSE 486/586, Spring 2013 Two-Phase Commit To deal with server crashes Each participant saves tentative updates into permanent storage, right before replying yes/no in first phase. Retrievable after crash recovery. To deal with canCommit? loss The participant may decide to abort unilaterally after a timeout (coordinator will eventually abort) To deal with Yes/No loss, the coordinator aborts the transaction after a timeout (pessimistic!). It must announce doAbort to those who sent in their votes. To deal with doCommit loss The participant may wait for a timeout, send a getDecision request (retries until reply received) – cannot abort after having voted Yes but before receiving doCommit/doAbort! 20

CSE 486/586, Spring 2013 Problems with 2PC It’s a blocking protocol. Other ways are possible, e.g., 3PC. Scalability & availability issues 21

CSE 486/586, Spring 2013 Summary Increasing concurrency –Non-exclusive locks –Two-version locks –Hierarchical locks Distributed transactions –One-phase commit cannot handle failures & abort well –Two-phase commit mitigates the problems of one-phase commit –Two-phase commit has its own limitation: blocking 22

CSE 486/586, Spring Acknowledgements These slides contain material developed and copyrighted by Indranil Gupta (UIUC).