We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byPatrick Rivera
Modified over 3 years ago
Database System Concepts 5 th Ed. © Silberschatz, Korth and Sudarshan, 2005 See for conditions on re-usewww.db-book.com Chapter 16 : Concurrency Control
©Silberschatz, Korth and Sudarshan16.2Database System Concepts - 5 th Edition, Sep 12, 2005 Chapter 16: Concurrency Control Lock-Based Protocols
©Silberschatz, Korth and Sudarshan16.3Database System Concepts - 5 th Edition, Sep 12, 2005 Lock-Based Protocols A lock is a mechanism to control concurrent access to a data item Data items can be locked in two modes : 1. exclusive (X) mode. Data item can be both read as well as written. X-lock is requested using lock-X instruction. 2. shared (S) mode. Data item can only be read. S-lock is requested using lock-S instruction. Lock requests are made to concurrency-control manager. Transaction can proceed only after request is granted. A locking protocol is a set of rules followed by all transactions while requesting and releasing locks. Locking protocols restrict the set of possible schedules.
©Silberschatz, Korth and Sudarshan16.4Database System Concepts - 5 th Edition, Sep 12, 2005 Lock-Based Protocols (Cont.) Lock-compatibility matrix A transaction may be granted a lock on an item if the requested lock is compatible with locks already held on the item by other transactions Any number of transactions can hold shared locks on an item, but if any transaction holds an exclusive on the item no other transaction may hold any lock on the item. If a lock cannot be granted, the requesting transaction is made to wait till all incompatible locks held by other transactions have been released. The lock is then granted.
©Silberschatz, Korth and Sudarshan16.5Database System Concepts - 5 th Edition, Sep 12, 2005 Lock-Based Protocols (Cont.) Consider that T 1 transfers $50 from account B to account A, and T 2 displays the total amount in A and B. Suppose that the values of A and B are $100 and $200, respectively. T 1 : lock-X(B); T 2 : lock-S(A); read(B); read(A); B := B - 50; unlock(A); write(B); lock-S(B); unlock(B); read(B); lock-X(A); unlock(B); read(A); display(A + B); A := A + 50; write(A); unlock(A); Executed serially, then T 2 displays $300. But executed concurrently(see Schedule 1), then T 2 display $250, which is incorrect. The reason is that T 1 unlocked data item B too early.
©Silberschatz, Korth and Sudarshan16.6Database System Concepts - 5 th Edition, Sep 12, 2005 Lock-Based Protocols (Cont.) T1 T2 lock-X(B) read(B) B := B – 50 write(B) unlock(B) lock-S(A) read(A) unlock(A) lock-S(B) read(B) unlock(B) display(A + B) lock-X(A) read(A) A := A + 50 write(A) unlock(A) Schedule 1.
©Silberschatz, Korth and Sudarshan16.7Database System Concepts - 5 th Edition, Sep 12, 2005 Lock-Based Protocols (Cont.) Suppose now that unlocking is delayed to the end of the transaction. T 3 and T 4 correspond to T 1 and T 2 with unlocking delayed, respectively: T3: lock-X(B); T4: lock-S(A); read(B); read(A); B := B - 50; lock-S(B); write(B); read(B); lock-X(A); display(A + B); read(A); unlock(A); A := A + 50; unlock(B); write(A); unlock(B); unlock(A);
©Silberschatz, Korth and Sudarshan16.8Database System Concepts - 5 th Edition, Sep 12, 2005 Pitfalls of Lock-Based Protocols Consider the partial schedule Neither T 3 nor T 4 can make progress executing lock-S(B) causes T 4 to wait for T 3 to release its lock on B, while executing lock-X(A) causes T 3 to wait for T 4 to release its lock on A. Such a situation is called a deadlock. To handle a deadlock one of T 3 or T 4 must be rolled back and its locks released.
©Silberschatz, Korth and Sudarshan16.9Database System Concepts - 5 th Edition, Sep 12, 2005 The Two-Phase Locking Protocol This is a protocol which ensures conflict-serializable schedules. Phase 1: Growing Phase transaction may obtain locks transaction may not release locks Phase 2: Shrinking Phase transaction may release locks transaction may not obtain locks The protocol assures serializability.
©Silberschatz, Korth and Sudarshan16.10Database System Concepts - 5 th Edition, Sep 12, 2005 The Two-Phase Locking Protocol (Cont.) Two-phase locking does not ensure freedom from deadlocks Cascading roll-back is possible under two-phase locking. To avoid this, follow a modified protocol called strict two-phase locking. Here a transaction must hold all its exclusive locks till it commits/aborts. Rigorous two-phase locking is even stricter: here all locks are held till commit/abort. In this protocol transactions can be serialized in the order in which they commit.
©Silberschatz, Korth and Sudarshan16.11Database System Concepts - 5 th Edition, Sep 12, 2005 Partial Schedule Under Two-Phase Locking Cascading rollback may occur under two-phase locking: Each transaction observes the two-phase locking protocol, but the failure of T 5 after the read(A) step of T 7 leads to cascading rollback of T 6 and T 7. Partial schedule under two-phase locking
©Silberschatz, Korth and Sudarshan16.12Database System Concepts - 5 th Edition, Sep 12, 2005 Lock Conversions Two-phase locking with lock conversions: – First Phase: can acquire a lock-S on item can acquire a lock-X on item can convert a lock-S to a lock-X (upgrade) – Second Phase: can release a lock-S can release a lock-X can convert a lock-X to a lock-S (downgrade) This protocol assures serializability.
©Silberschatz, Korth and Sudarshan16.13Database System Concepts - 5 th Edition, Sep 12, 2005 Lock Conversions Rigorous two-phase locking protocol: requires all locks to be held until the transaction commits. Consider T 8 : read(a 1 ); T 9 : read(a 1 ); read(a 2 ); read(a 2 );... display(a 1 + a 2 ). read(a n ); write(a 1 ). Two-phase locking protocol ==> serial
©Silberschatz, Korth and Sudarshan16.14Database System Concepts - 5 th Edition, Sep 12, 2005 Lock Conversions If we employ the two-phase locking protocol, then T 8 must lock a 1 in exclusive mode. Therefore, any concurrent execution of both transactions amounts to a serial execution. Notice, however, that T 8 needs an exclusive lock on a 1 only at the end of its execution, when it writes a 1. Thus, if T 8 could initially lock a1 in shared mode, and then could later change the lock to exclusive mode, we could get more concurrency, since T 8 and T 9 could access a 1 and a 2 simultaneously. lock conversion: - upgrade: shared exclusive modes in growing phase. - downgrade: exclusive shared mode in shrinking phase.
©Silberschatz, Korth and Sudarshan16.15Database System Concepts - 5 th Edition, Sep 12, 2005 Incomplete Schedule With a Lock Conversion See the incomplete schedule with a lock conversion. Strict two-phase locking and rigorous two-phase locking (with lock conversions) are used extensively in commercial database systems.
Database System Concepts 5 th Ed. © Silberschatz, Korth and Sudarshan, 2005 See for conditions on re-usewww.db-book.com End of Chapter 16
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
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.
Concurrency Control Lectured by, Jesmin Akhter, Assistant professor, IIT, JU.
1 Concurrency control lock-base protocols timestamp-based protocols validation-based protocols Ioan Despi.
Lecture 8- Concurrency Control Advanced Databases Masood Niazi Torshiz Islamic Azad university- Mashhad Branch
Chapter 15 Concurrency Control Yonsei University 1 st Semester, 2015 Sanghyun Park.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15 : Concurrency.
Concurrency Control WXES 2103 Database. Content Concurrency Problems Concurrency Control Concurrency Control Approaches.
CM20145 Concurrency Control Dr Alwyn Barry Dr Joanna Bryson.
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Concurrency Control 2004, Spring Pusan National University Ki-Joune Li.
Concurrency Control Enforcing Serializability by Locks Krishna Nitin Tenali.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
15.1Database System Concepts - 6 th Edition Chapter 15: Concurrency Control Lock-Based Protocols The Two-Phase Locking Protocol Graph-Based Protocols #Deadlock.
©Silberschatz, Korth and Sudarshan15.1Database System Concepts - 6 th Edition Concurrency Control Concurrency Control Introduction Lock-Based Protocols.
CM20145 Recovery + Intro. to Concurrency Dr Alwyn Barry Dr Joanna Bryson.
José Alferes Versão modificada de Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan Chapters 15-17: Transaction Management Transactions,
Concurrency control 1. 2 Introduction concurrency more than one transaction have access to data simultaneously part of transaction processing.
Concurrency Control. General Overview Relational model - SQL Formal & commercial query languages Functional Dependencies Normalization Transaction Processing.
Concurrency Control By Donavon Norwood Ankit Patel Aniket Mulye 1.
1 Concurrency Control By Ankit Patel. 2 INTRODUCTION Enforcing serializability by locks Locks Locking scheduler Two phase locking Locking systems with.
Quick Review of Apr 29 material Transformation of Relational Expressions –Equivalence Rules Transactions –ACID properties (Atomic, Consistent, Isolated,
Transaction Management Dale-Marie Wilson, Ph.D.. Transaction Support Transaction Action, or series of actions, carried out by user or application, which.
Computing & Information Sciences Kansas State University Wednesday, 14 Nov 2007CIS 560: Database System Concepts Lecture 34 of 42 Wednesday, 14 November.
Databases Illuminated Chapter 10 Transaction Management.
1 Term 2, 2004, Lecture 6, TransactionsMarian Ursu, Department of Computing, Goldsmiths College Transactions 3.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
Concurrency Control in Database Operating Systems.
1 Database Systems ( 資料庫系統 ) December 24/26, 2007 Lecture 13.
1 CS 728 Advanced Database Systems Chapter 21 Introduction to Protocols for Concurrency Control in Databases.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 16: Recovery.
Concurrency Control Amol Deshpande CMSC424. Approach, Assumptions etc.. Approach Guarantee conflict-serializability by allowing certain types of concurrency.
V. Megalooikonomou Concurrency control (based on slides by C. Faloutsos at CMU and on notes by Silberchatz,Korth, and Sudarshan) Temple University – CIS.
Lecture 9- Concurrency Control (continued) Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
1 Chapter 5 Concurrency Control Techniques Adapted from the slides of Fundamentals of Database Systems (Elmasri et al., 2003)
CSC271 Database Systems Lecture # 32. Summary: Previous Lecture Database security Countermeasure: computer-based controls DBMSs and web security.
1 Concurrency Control. 2 Lock-Based Protocols Multiple Granularity Deadlock Timestamp-Based Protocols.
7c.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Module 7c: Atomicity Atomic Transactions Log-based Recovery Checkpoints Concurrent.
Lock-Based Concurrency Control. When multiple transactions are trying to access the same sharable resource, there could arise many problems if the access.
Concurrency Control Concurrency Control By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
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)
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Prepared by: Mudra Patel (113) Locking Scheduler & Managing Hierarchies of Database Elements.
Jane Reid, BSc/IT DB, QMUL, 11/3/02 1 Lecture plan Transaction processing Concurrency control Recovery techniques.
ICS (072)Concurrency Control Techniques1 Concurrency Control Techniques Chapter 18 Dr. Muhammad Shafique.
© 2017 SlidePlayer.com Inc. All rights reserved.