CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.

Slides:



Advertisements
Similar presentations
Database System Concepts 5 th Ed. © Silberschatz, Korth and Sudarshan, 2005 See for conditions on re-usewww.db-book.com Chapter 16 : Concurrency.
Advertisements

CM20145 Concurrency Control
Database Systems (資料庫系統)
Concurrency Control WXES 2103 Database. Content Concurrency Problems Concurrency Control Concurrency Control Approaches.
Chapter 16 Concurrency. Topics in this Chapter Three Concurrency Problems Locking Deadlock Serializability Isolation Levels Intent Locking Dropping ACID.
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
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 II. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
Lock-Based Concurrency Control
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.
Sekolah Tinggi Ilmu Statistik (STIS) 1 Dr. Said Mirza Pahlevi, M.Eng.
Quick Review of Apr 29 material
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Transaction Management
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Concurrency Control John Ortiz.
CS4432transaction management1 CS4432: Database Systems II Lecture #23 Transaction Management Professor Elke A. Rundensteiner.
15.1Database System Concepts - 6 th Edition Chapter 15: Concurrency Control Lock-Based Protocols The Two-Phase Locking Protocol Graph-Based Protocols #Deadlock.
Concurrency Control.
Databases Illuminated
V. Megalooikonomou Concurrency control (based on slides by C. Faloutsos at CMU and on notes by Silberchatz,Korth, and Sudarshan) Temple University – CIS.
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.
Chapter 15 Concurrency Control Yonsei University 1 st Semester, 2015 Sanghyun Park.
Concurrency Control Concurrency Control By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
Concurrency Control Introduction Lock-Based Protocols
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 8 Concurrency Control 8.1 Lock-Based Protocols 8.2 Multiple Granularity 8.3 Deadlock Handling 8.4 Insert and Delete Operations.
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.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15 : Concurrency.
Academic Year 2014 Spring Academic Year 2014 Spring.
DBMS Deadlock.
Transaction Management
Concurrency Control Managing Hierarchies of Database Elements (18.6)
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.
Part- A Transaction Management
Chapter 7: Concurrency Control
Chapter 16: Concurrency Control
Chapter 16: Concurrency Control
4. Concurrency control techniques
Chapter 16: Concurrency Control
Database System Implementation CSE 507
Chapter 10 Transaction Management and Concurrency Control
Chapter 16: Concurrency Control
Database System Implementation CSE 507
Concurrency Control.
Chapter 16: Concurrency Control
Concurrency Control WXES 2103 Database.
Ch 22: Databases Concurrency Control
Chapter 15 : Concurrency Control
Concurrency Unit 4.2 Dr Gordon Russell, Napier University
Module 16 : Concurrency Control
Chapter 16: Concurrency Control
Temple University – CIS Dept. CIS661 – Principles of Data Management
Database Management System
Chapter 16 : Concurrency Control
Database Systems (資料庫系統)
Database Systems (資料庫系統)
Transactions, Properties of Transactions
Presentation transcript:

CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel activities, that do not interact, have simple concurrency issues. It is when parallel activities interact or share the same resources that concurrency issues become important.

NEED FOR CONCURRENCY One transaction is reading several values from the common (shared data item) and the other transaction updates the record concurrently. The outcome of the first transaction will go wrong in this case.

CONCURRENCY CONTROL Activity of coordinating concurrent access to a database in a multi user database management system ( i.e ) managing simultaneous operations on the database without having interference with one another.

LOCK A lock is a mechanism to control concurrent access to a data item. If one transaction is accessing data item, then no other transaction can modify that 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.

The lock manager maintains a data-structure called a lock table to record granted locks and pending requests. Any number of transactions can hold shared locks on an item, but if any transaction holds an X-Lock on the item, then 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.

LOCKING PROTOCOLS Set of rules followed by all transactions while requesting and releasing locks (i.e) while locking and unlocking the data items. Neither T3 nor T4 can make progress. Executing lock-S(B)–T4 wait for T3 to unlock B. Executing lock-X(A)-T3 wait for T4 to unlock A. Such a situation is called dead lock. To handle deadlock: One of T3 or T4 must release its lock Or must be rolled back.

Initially, a transaction is in growing phase. TWO PHASE LOCKING PROTOCOL 2PL protocol requires that each transaction issue lock or unlock requests in two phases: GROWING PHASE : a transaction may obtain locks but may not release any lock. SHRINKING PHASE : a transaction may release locks but may not obtain any new lock. Initially, a transaction is in growing phase. Acquires locks as much as it needs. Once it acquired enough locks, it releases a lock and enters shrinking phase.

STRICT TWO PHASE LOCKING A second transaction goes to wait state , if locked out by first. First come, First served will make sure the second one is next when the first releases lock. All locks requested by a transaction are held until the transaction is completed ( commits or aborts ), at which point the locks are released.

GRAPH BASED PROTOCOLS An alternative to two phase locking. Eg : Tree Protocol. Only exclusive locks are allowed. The first lock by Ti may be on any data item. Subsequently, a data D can be locked by Ti only if the parent of D is currently locked by Ti. Data items may be unlocked at any time. A data item that has been locked and unlocked by Ti cannot subsequently be relocked by Ti Transactions may have to lock the data items that they do not access.

INTENT LOCKING Only the intention of locking is expressed at the ancestor node of the required resource. The resource at the lower level is locked explicitly only when required. Allows a higher level node to be locked in S or X mode without having to check all descendant nodes.

In addition to S and X lock modes, there are three additional lock modes with multiple granularity: intention-shared (IS): indicates explicit locking at a lower level of the tree but only with shared locks. intention-exclusive (IX): indicates explicit locking at a lower level with exclusive or shared locks shared and intention-exclusive (SIX): the sub tree rooted by that node is locked explicitly in shared mode and explicit locking is being done at a lower level with exclusive-mode locks.

DEADLOCK System is deadlocked if there is a set of transactions such that every transaction in the set is waiting for another transaction in the set. STEPS TO HANDLE DEADLOCK: Deadlock Prevention: Ensures that the system will never enter in deadlock state. Deadlock Detection & Recovery: If the system enters in deadlock, it tries to recover from deadlock state.

DEADLOCK PREVENTION Two schemes of Deadlock Prevention: wait-die scheme — non-preemptive older transaction may wait for younger one to release data item. they are rolled back instead. a transaction may die several times before acquiring needed data item. wound-wait scheme — preemptive older transaction wounds (forces rollback) of younger transaction instead of waiting for it. Younger transactions may wait for older ones. may be fewer rollbacks than wait-die scheme.

RECOVERY FROM DEADLOCK When a deadlock detection algorithm determines that a deadlock exists, the system must recover from the deadlock. The most common solution is to rollback one or more transactions. THREE actions to be taken to recover from deadlock are: 1. Selection : The transaction which caused the deadlock is chosen as the victim and is rolled back to break the deadlock. 2. Rollback: Determines how far to roll back transaction. TOTAL ROLLBACK: Abort the transaction and restart it. PARTIAL ROLLBACK: Rollback as far as needed to break the deadlock.

3. Starvation: Its possible that, same transaction will be rolled back number of times to break the deadlock. As a result, this transaction never completes its designated task. Thus, there is starvation. To avoid this, we must ensure that transactions can be picked as a victim only a small number of times.