© 1997 UW CSE 11/13/97N-1 Concurrency Control Chapter 18.1, 18.2, 18.5, 18.7.

Slides:



Advertisements
Similar presentations
Lecture plan Transaction processing Concurrency control
Advertisements

Database Systems Lecture 16 Natasha Alechina
1 Concurrency Control III Dead Lock Time Stamp Ordering Validation Scheme.
Database Systems (資料庫系統)
Unit 9 Concurrency Control. 9-2 Wei-Pang Yang, Information Management, NDHU Content  9.1 Introduction  9.2 Locking Technique  9.3 Optimistic Concurrency.
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
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.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
Concurrency Control.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
CS 728 Advanced Database Systems Chapter 21 Introduction to Protocols for Concurrency Control in Databases.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 6: Cascading Rollbacks, Deadlocks, and Long Transactions Professor Chen Li.
1 More Transaction Management Concurrency control and recovery Resolving deadlocks Logical logging Source: slides by Hector Garcia-Molina.
Sekolah Tinggi Ilmu Statistik (STIS) 1 Dr. Said Mirza Pahlevi, M.Eng.
Quick Review of Apr 29 material
Concurrent Transactions Even when there is no “failure,” several transactions can interact to turn a consistent state into an inconsistent state.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
CS 582 / CMPE 481 Distributed Systems Concurrency Control.
CS 245Notes 101 CS 245: Database System Principles Notes 10: More TP Hector Garcia-Molina.
ACS-4902 R. McFadyen 1 Database Concurrency Control Deadlock Deadlock occurs when each transaction in a set is waiting for another transaction in the set.
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.
Concurrency Control John Ortiz.
CS346: Advanced Databases Graham Cormode Concurrency Control.
CS4432transaction management1 CS4432: Database Systems II Lecture #23 Transaction Management Professor Elke A. Rundensteiner.
DBMS2001Notes 9: Transaction Processing1 Principles of Database Management Systems 9: More on Transaction Processing Pekka Kilpeläinen (Partially based.
Concurrency Control In Dynamic Database Systems Laurel Jones.
CS 245Notes 101 CS 245: Database System Principles Notes 10: More TP Hector Garcia-Molina.
ICS (072)Concurrency Control Techniques1 Concurrency Control Techniques Chapter 18 Dr. Muhammad Shafique.
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
Concurrency control. Lock-based protocols One way to ensure serializability is to require the data items be accessed in a mutually exclusive manner One.
Chapter 15 Concurrency Control Yonsei University 1 st Semester, 2015 Sanghyun Park.
Chapter 18 Concurrency Control Techniques Copyright © 2004 Pearson Education, Inc.
1 Concurrency Control Chapter Conflict Serializable Schedules  Two schedules are conflict equivalent if:  Involve the same actions of the same.
Overview of DBMS recovery and concurrency control: Eksemplerne er fra kapitel 3 I bogen: Lars Fank Databaser Teori og Praksis ISBN
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Lec 9 Concurrency Control Techniques.
Concurrency Control Introduction Lock-Based Protocols
Chapter 8 Concurrency Control 8.1 Lock-Based Protocols 8.2 Multiple Granularity 8.3 Deadlock Handling 8.4 Insert and Delete Operations.
1 Database Systems ( 資料庫系統 ) December 27, 2004 Chapter 17 By Hao-hua Chu ( 朱浩華 )
1 CSE232A: Database System Principles More Concurrency Control and Transaction Processing.
1 Lecture 4: Transaction Serialization and Concurrency Control Advanced Databases CG096 Nick Rossiter [Emma-Jane Phillips-Tait]
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Concurrency Control The main reference of this presentation is the textbook and PPT from : Elmasri & Navathe, Fundamental of Database Systems, 4th edition,
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
DBMS Deadlock.
Transaction Management
CS 245: Database System Principles Notes 10: More TP
Lecture 3 Concurrency control techniques
Concurrency Control Techniques
Concurrency Control.
Multiple Granularity Granularity is the size of data item  allowed to lock. Multiple Granularity is the hierarchically breaking up the database into portions.
4. Concurrency control techniques
Chapter 10 Transaction Management and Concurrency Control
Outline Introduction Background Distributed DBMS Architecture
Ch 22: Databases Concurrency Control
Chapter 15 : Concurrency Control
Concurrency Control Chapter 17
Concurrency Control Techniques
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Transactions, Properties of Transactions
Presentation transcript:

© 1997 UW CSE 11/13/97N-1 Concurrency Control Chapter 18.1, 18.2, 18.5, 18.7

11/13/97N-2 Locks A lock is associated with each (lockable) item in the DB –describes status of that item Main idea: transaction must lock an item before using it. Con: added overhead; decreased parallelism Pro: used properly, locks guarantee that schedules are serializable

11/13/97N-3 Binary Locks Binary lock: statuses are "locked" and "unlocked" Rules for use (just common sense, or common courtesy): –T must lock item before reading or writing it. –T must unlock item when finished with it. –T will not try to lock an item it's already locked. –T will not try to unlock an item it doesn't already have locked. Implementation: Queue of waiting T's.

11/13/97N-4 Multimode Locks Only slightly more complicated Three states: –read-locked ("shared-locked") –write-locked ("exclusive-locked) –unlocked Multiple T's can hold the item read-locked, only one can write-lock it. Rules of common courtesy similar to binary locks

11/13/97N-5 Are Locks Enough?  Sadly… no. Locks alone do not guarantee serializability. Happily… there is a simple protocol (2PL) which uses locks to guarantee serializability. –Easy to explain –Easy to implement –Easy to enforce

11/13/97N-6 The Two-Phase Locking Protocol T is said to follow the 2PL if all lock operations precede the first unlock. T must also follow the courtesy rules, of course Such a T has two phases: –Expanding: locks but no unlocks –Shrinking: unlocks but no locks

11/13/97N-7 2PL is Good Stuff 2PL is widely used –Can be adapted to variety of situations, such as distributed processing Variations: –Basic 2PL (as described) –Conservative 2PL: T locks all items before execution –Strict 2PL: T doesn't unlock any items until after COMMIT or ABORT.

11/13/97N-8 But is it the last word? Is there a snake in the Garden of Eden? 2PL reduces concurrency  –Conservative and strict variants reduce it even more, because they hold locks longer. Basic and strict 2PL are both subject to deadlock 

11/13/97N-9 Deadlock Deadlock occurs when two transactions are each waiting for the other –e.g., each waiting for a lock that the other holds –can also be deadlocks in larger circles of T's 2PL is not deadlock-free Two possible approaches: –Deadlock prevention (don’t let it happen) –Deadlock detection (notice when it's happened and take recovery action)

11/13/97N-10 Deadlock Prevention Using Timestamps Transaction timestamps: unique numerical identifiers, same order as the starting order of the T's. –Notation: TS(T i ) –Not necessarily a system clock value –Could be simply integer++ for each T Interesting factoid: global timestamp techniques can be used in distributed systems, even when each system has its own clock.

11/13/97N-11 Two TS Schemes Suppose T j has locked X, and now T i wants to lock X. Wait-die: if TS(T i )<TS(T j ) then T i is allowed to wait else T i dies and is restarted with its same TS. Wound-wait: if TS(T i )<TS(T j ) then abort T j and restart with its same TS else Ti is allowed to wait.

11/13/97N-12 TS Schemes In both schemes, the older T has a certain preferential treatment. –An aborted and restarted T always keeps it original TS. –Thus it gets older with respect to the other Ts, so eventually it gets the preference.

11/13/97N-13 Deadlock Prevention Without Timestamps No waiting: If T needs X and X is already locked, immediately abort T, restart later. –May cause lots of restarting Cautious waiting: Suppose T i needs X, and X is already locked by T j. If T j is waiting for anything, then abort T j else abort T i. Timeout: If T waits longer than some fixed time, abort and restart T.

11/13/97N-14 Deadlock Detection Simple idea: –Do nothing to prevent deadlocks –Make a check periodically to see if there are deadlock; if so, chose victim(s) to abort Pro: no elaborate protocols needed Con: deadlock might go undetected for a while Deadlocks tend to be rare on lightly loaded systems, frequent on heavily loaded systems

11/13/97N-15 Detection Algorithm "Wait-for" graph: –One node per T –Directed edge T i  T j if T i wants to lock X which is already locked by T j. Theorem: There is a deadlock iff the wait-for graph has a cycle. Issues –When to run the algorithm –How to select the victims

11/13/97N-16 Starvation and Livelock Another snake in the Garden of Eden A T might be aborted and restarted indefinitely: Starvation A T might wait indefinitely, not for the same other T (deadlock), but for different reasons at different times: Livelock Footnote: Some people use "starvation" for either situation.

11/13/97N-17 Concurrency Control Using Timestamp Ordering Main idea: insure that conflicting operations occur in timestamp order Each item X must have a read TS and a write TS –= TS's of the T which last read or wrote X If T wants to use X, then X's TSs are checked. For a conflicting operation, TS(T) must be later. If not, T is aborted and restarted with a new (later) TS.

11/13/97N-18 TO Properties Guarantees serializability –in fact, guarantees conflict serializability Deadlock free Not starvation free  –You hope that eventually T becomes "late enough" to slide through, but that might never happen.