14/06/2015Distribuerede Systemer1 Concurrency Control Thomas Hildebrandt.

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 16: Transactions.
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
CS 542: Topics in Distributed Systems Transactions and Concurrency Control.
University of Tampere, CS Department Distributed Transaction Management Jyrki Nummenmaa
Principles of Transaction Management. Outline Transaction concepts & protocols Performance impact of concurrency control Performance tuning.
Concurrency Control II
Concurrency Control Amol Deshpande CMSC424. Approach, Assumptions etc.. Approach  Guarantee conflict-serializability by allowing certain types of concurrency.
CS6223: Distributed Systems
Lock-Based Concurrency Control
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
1 Supplemental Notes: Practical Aspects of Transactions THIS MATERIAL IS OPTIONAL.
Exercises for Chapter 17: Distributed Transactions
1 TRANSACTION & CONCURRENCY CONTROL Huỳnh Văn Quốc Phương Thái Thị Thu Thủy
Transactions and concurrency control
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Distributed Systems Fall 2010 Transactions and concurrency control.
Concurrency Control R&G - Chapter 17 Smile, it is the key that fits the lock of everybody's heart. Anthony J. D'Angelo, The College Blue Book.
CS 582 / CMPE 481 Distributed Systems Concurrency Control.
Transaction Management and Concurrency Control
Transaction Management
ICS (072)Concurrency Control1 Transaction Processing and Concurrency Control Dr. Muhammad Shafique Chapter March 2008.
ACS-4902 R. McFadyen 1 Chapter 18 Database Concurrency Control Locking 18.1 Shared/Exclusive (aka Read/Write) Locks Lock Operations Read_lock(X) Write_lock(X)
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
© 1997 UW CSE 11/13/97N-1 Concurrency Control Chapter 18.1, 18.2, 18.5, 18.7.
Transactions and concurrency control
Distributed Deadlocks and Transaction Recovery.
Exercises for Chapter 16: Transactions and Concurrency Control
Data Concurrency Control And Data Recovery
Distributed Transactions
Chapter 12 Transactions 12.1 Introduction 12.2 Transactions 12.3Nested Transactions 12.4 Locks.
Databases Illuminated
CSE 486/586, Spring 2013 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,
ICS (072)Concurrency Control Techniques1 Concurrency Control Techniques Chapter 18 Dr. Muhammad Shafique.
Concurrency Control Lectured by, Jesmin Akhter, Assistant professor, IIT, JU.
Chapter 11 Concurrency Control. Lock-Based Protocols  A lock is a mechanism to control concurrent access to a data item  Data items can be locked in.
Transactions CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
Concurrency Control Techniques Chapter 18
Chapter 15 Concurrency Control Yonsei University 1 st Semester, 2015 Sanghyun Park.
Distributed Systems Course Transactions and Concurrency Control 12.1Introduction 12.2Transactions 12.3Nested transactions 12.4Locks 12.5Optimistic concurrency.
Concurrency Server accesses data on behalf of client – series of operations is a transaction – transactions are atomic Several clients may invoke transactions.
Concurrency Control Concurrency Control By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
Chapter 18 Concurrency Control Techniques Copyright © 2004 Pearson Education, Inc.
Distributed Transactions Chapter – Vidya Satyanarayanan.
Distributed Processing Systems ( Concurrency Control ) 오 상 규 서강대학교 정보통신 대학원
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Concurrency Control Introduction Lock-Based Protocols
1 Concurrency control lock-base protocols timestamp-based protocols validation-based protocols Ioan Despi.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
Slides for Chapter 12: Transactions and Concurrency Control From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3,
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Slides for Chapter 12: Transactions and Concurrency Control From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3,
Lecture 9- Concurrency Control (continued) Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Concurrency Control 2004, Spring Pusan National University Ki-Joune Li.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15 : Concurrency.
Lecture 3 Concurrency control techniques
Concurrency Control Techniques
Concurrency Control.
Chapter 10 Transaction Management and Concurrency Control
Chapter 15 : Concurrency Control
Exercises for Chapter 14: Distributed Transactions
UNIVERSITAS GUNADARMA
Slides for Chapter 12: Transactions and Concurrency Control
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Presentation transcript:

14/06/2015Distribuerede Systemer1 Concurrency Control Thomas Hildebrandt

14/06/2015Distribuerede Systemer2 Agenda concurrency control protocols: challenges pessimistic concurrency control –Locks (strict) two-phase locking –Deadlocks prevention and detection distributed deadlocks –Increasing concurrency fine-grained locking, two-version locking, nested transactions optimistic concurrency control –working, validation and updating phase

14/06/2015Distribuerede Systemer3 Concurrency Control Protocols challenges recall the notions of –isolation, serial equivalence and conflicting operations challenge of concurrency control protocols: –guarantee isolation property and maximize concurrency –may be used without using transactions (e.g. the CORBA Concurrency Control Service), –but if used with transactions, we must consider aborts pessimistic versus optimistic approach: –avoid conflicts (locking) or resolve conflicts (aborting)

14/06/2015Distribuerede Systemer4 Locks Two-phase locking a lock controls access to an object: –a lock can be acquired and released –simplest locks are exclusive locks transaction manager employs a lock manager that controls a lock for each shared object two-phase locking –growing phase & shrinking phase: no new locks after having released a lock –guarantees serial equivalence in absense of failures/aborts what may go wrong?

14/06/2015Distribuerede Systemer5 Considering aborts Strict two-phase locking recall that aborts may lead to –dirty reads (, cascading aborts) and –premature writes to avoid this we ensure strict execution: –no reads and writes on objects with non-comitted updates this is guaranteed by strict two-phase locking –hold locks until commit (and everything is saved) or abort –have to wait to all have committed in distributed settings What may still go wrong?

14/06/2015Distribuerede Systemer6 Deadlocks definition a state in which each member of a group of transactions is waiting for some other member to release a lock This situation can be represented by a wait-for graph: B A Waits for Held by T U U T Waits for

14/06/2015Distribuerede Systemer7 Additional deadlock conditions Two or more processes share resources which they use under mutual exclusion (for instance by using locks) Incremental acquisition No preemption

14/06/2015Distribuerede Systemer8 Dealing with deadlocks Deadlock prevention –rule out one or more of the conditions for deadlock, for instance by locking in a fixed order or pre-lock Deadlock detection –alternatively one may try to detect deadlocks –to resolve the deadlock a transaction must be aborted Timeouts on locks –common, but may lead to unnecessary aborts –penalizes long transactions

14/06/2015Distribuerede Systemer9 Distributed Deadlocks global wait-for graphs: D Waits for Waits for Held by Held by B Waits for Held by X Y Z Held by W U V A C W V U

14/06/2015Distribuerede Systemer10 Global wait-for graphs phantom deadlocks X TU Y VT T U V local wait-for graph global deadlock detector may use edge-chasing algorithm instead

14/06/2015Distribuerede Systemer11 Increasing Concurrency fine-grained locking read & write locks –allow many concurrent readers –policy issues (fairness) hierarchic locks –locking with mixed granularity nested transactions two-version locking –tentative versions

14/06/2015Distribuerede Systemer12 Read and write locks Figure 12.15: Lock compatibility For one objectLock requested readwrite Lock already set noneOK readOKwait writewait - what should happen in strict two-phase locking, if a transaction first gets a READ lock, and then asks for a WRITE lock on the same object?

14/06/2015Distribuerede Systemer13 Use of locks in strict two-phase locking Figure 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.

14/06/2015Distribuerede Systemer14 Lock Implementation Figure 12.17, acquire public class Lock { private Object object;// the object being protected by the lock private Vector holders; // the TIDs of current holders private LockType lockType; // the current type public synchronized void acquire(TransID trans, LockType aLockType ){ while(/*another transaction holds the lock in conflicing mode*/) { try { wait(); }catch ( InterruptedException e){/*...*/ } } if(holders.isEmpty()) { // no TIDs hold lock holders.addElement(trans); lockType = aLockType; } else if(/*another transaction holds the lock, share it*/ ) ){ if(/* this transaction not a holder*/) holders.addElement(trans); } else if (/* this transaction is a holder but needs a more exclusive lock*/) while(!lockType.promote(aLockType)){ try{wait(); } catch(InterruptedException e)){/*...*/ } }

14/06/2015Distribuerede Systemer15 Lock Implementation Figure 12.17, release public synchronized void release(TransID trans ){ holders.removeElement(trans); // remove this holder // set locktype to none notifyAll(); }

14/06/2015Distribuerede Systemer16 Increasing Concurrency Hierarchic Locks - Figure Diary-example: locking with mixed granularity: Week MondayTuesdayWednesdayThursdayFriday 9:00–10:00 time slots 10:00–11:0011:00–12:0012:00–13:0013:00–14:0014:00–15:0015:00–16:00 Use intention locks to get efficient locking

14/06/2015Distribuerede Systemer17 Lock compatibility table for hierarchic locks Figure For one object Lock to be set readwriteI-readI-write Lock already set none OK read OKwaitOKwait write wait I-read OKwaitOK I-write wait OK

14/06/2015Distribuerede Systemer18 Increasing Concurrency Nested transactions children borrows locks parent inherit locks from children why may use of nested transactions increase concurrency?

14/06/2015Distribuerede Systemer19 Increasing Concurrency Two-version locking "optimistic scheme" –write to tentative versions –read tentative or last committed values –check at commit time for conflicts –uses read, write and commit locks comparison with one-version locking: –read operations only delayed during commit –read operations may cause delay in other committing transactions

14/06/2015Distribuerede Systemer20 Lock compatibility table (read, write, commit) Figure For one objectLock to be set readwritecommit Lock already setnoneOK readOK wait writeOKwait commitwait

14/06/2015Distribuerede Systemer21 Optimistic Concurrency Control drawbacks of locking: –lock maintance is an overhead, only needed in worst case –may lead to deadlocks, deadlock prevention reduces concurrency Instead one may take an optimistic approach: –no locking –working, validation and update phase –use tentative versions in working phase (like two-version locking)

14/06/2015Distribuerede Systemer22 Optimistic Concurrency Control Working phase: –use tentative versions (as two-version locking, but no locks!) –several different values of an object may coexist –keep record of objects accessed: –read set and write set Validation phase –starts at closeTransaction request, –assign transaction number, acts as a "pseudo clock" –validate order of conflicting pairs wrt. overlapping transactions (not yet committed)

14/06/2015Distribuerede Systemer23 Optimistic Concurrency Control validation of transaction T TTiTi Rule writeread1.TiTi must not read objects written byT readwrite2.T must not read objects written byTiTi write 3.TiTi must not write objects written byTand T mustnot write objects written byTiTi may make update phase mutual exclusive, (- use locks) either validate backward or forward

14/06/2015Distribuerede Systemer24 Validation of transactions Figure Earlier committed transactions WorkingValidationUpdate T 1 T v Transaction being validated T 2 T 3 Later active transactions active 1 2

14/06/2015Distribuerede Systemer25 Validation backward –write-only transactions always pass –must keep old write sets –can only abort the transaction under validation to resolve forward –read-only transactions always pass –read sets of active may change during validation –can choose alternative resolvation (abort active in conflict) starvation –transactions are normally restarted after aborts, we say they starve if they keep aborting this way

14/06/2015Distribuerede Systemer26 Optimistic Concurrency Control distributed transactions local concurrency control –validation takes place in phase one at each server –commitment deadlock may occur if using exclusive validation parallel validation –must check rule 3 as well need to ensure global order –finish with a global validation, or –issue globally unique transaction numbers

14/06/2015Distribuerede Systemer27 Timestamp ordering validation on the fly assign unique timestamp at openTransaction –check conflicts on the fly –as two-version locking, but decides order statically

14/06/2015Distribuerede Systemer28 Summary and conclusions concurrency control protocols must ensure isolation - and allow for recovery they all induce an overhead and limit the potential for concurrent operation locking may lead to deadlocks optimistic approaches more efficient if few conflicts, mut may lead to late aborts timestamp ordering decides order statically and aborts immediately distributed transactions: distributed control