Academic Year 2014 Spring Academic Year 2014 Spring.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Deadlock Prevention, Avoidance, and Detection
Deadlock and Starvation
Deadlock Prevention, Avoidance, and Detection.  The Deadlock problem The Deadlock problem  Conditions for deadlocks Conditions for deadlocks  Graph-theoretic.
Concurrency Control Amol Deshpande CMSC424. Approach, Assumptions etc.. Approach  Guarantee conflict-serializability by allowing certain types of concurrency.
Chapter 7: Deadlocks.
Concurrency Control.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
7.5 Deadlock Avoidance The algorithm is simply to ensure that the system will always remain in safe state. Therefore, if a process requests a resource.
Chapter 7 Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks 7.1 System Model.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 30 Handling Deadlock.
Quick Review of Apr 29 material
Chapter 7. Deadlocks.
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.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
1 Chapter 7: Deadlock. 2 The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Deadlock CSCI 444/544 Operating Systems Fall 2008.
Transaction Management
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Bridge Crossing Example Traffic only in one direction. Each section.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Silberschatz, Galvin and Gagne  Operating System Concepts Deadlock and Starvation Deadlock – two or more processes are waiting indefinitely for.
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
Academic Year 2014 Spring Academic Year 2014 Spring.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks.
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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Operating Systems Part III: Process Management (Deadlocks)
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
Chapter 7 Deadlocks Page 2 Chapter 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
Chapter 7 Deadlocks Chapter 7: Deadlocks 7.1 System Model 7.2 Deadlock Characterization 7.3 Methods for Handling Deadlocks 7.4 Deadlock Prevention 7.5.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks System Model Deadlock Characterization Methods.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 7 Operating Systems.
Operating Systems Unit VI Deadlocks and Protection Department of Computer Science Engineering and Information Technology.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
Chapter 7: Deadlocks. 7.2CSCI 380 – Operating Systems Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
CS307 Operating Systems Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15 : Concurrency.
DBMS Deadlock.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
Deadlock Operating Systems (CC2011NI) -Mr. Pranoy Man Pradhan.
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 7: Deadlocks.
Deadlock Detection & recovery
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.
Chapter 7: Deadlocks.
Chapter 7 Deadlocks.
Chapter 7: Deadlocks.
Process Deadlocks.
Outline Introduction Background Distributed DBMS Architecture
Chapter 15 : Concurrency Control
Chapter 8: Deadlocks.
DEADLOCK.
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:

Academic Year 2014 Spring Academic Year 2014 Spring

MODULE CC3005NI: Advanced Database Systems “DATABASE CONCURRENCY” (PART – 2) Academic Year 2014 Spring Academic Year 2014 Spring

 We have seen that how locking can be applied to solve the three basic concurrency problems identified.  However, it has been shown that locking can lead to problems of its own: DEADLOCK Deadlock:

 A system is in a state of Deadlock if there exists a set of transactions such that every transaction in the set is waiting for another transaction in the set. or wait  Deadlock is a situation in which two or more transactions are in a simultaneous wait state, each of them waiting for one of the others to release a lock before it can proceed. Deadlock Problem:

 Where p1 and p2 are data items At time t4, both transactions A and B are deadlocked and neither is able to proceed any further Deadlock Problem - Example:

 Two main methods for deadlock handling  Deadlock Prevention o This method is used to ensure that the system will never enter a deadlock state.  Deadlock Detection and Recovery o This allows the system to enter a deadlock state then attempts to recover from it using a deadlock detection and recovery scheme.  Both methods may result in transaction rollback and both incur overheads. Deadlock Handling:

 Each transaction locks all its required data items before it begins execution.  Either all data items needed are locked in one step (so the transaction can then proceed) or none are locked (to avoid locking only some of the data items needed) This scheme could be used if the probability of the system entering a deadlock state is relatively high ( for example; for long transactions needing many locks) Deadlock Prevention Scheme:

 Disadvantages of the scheme  Low data utilisation o Some data items could be locked for a long time before they are used.  Possible starvation o A transaction which requires a number of data items may find itself in a indefinite wait state while at least one of the data items is always locked by some other transactions. Note that there are other deadlock prevention schemes. Deadlock Prevention Scheme:

 Basic Idea:  The state of the system is examined periodically to detect whether a deadlock has occurred in the system  If it has, the system attempts to recover from the deadlock (often involving rollback) This scheme is commonly used if the deadlock probability in the system is relatively low (for example; for short transactions needing only a few data items) Deadlock Detection & Recovery:

 General Procedure:  Maintain information about the current allocation of data items to different transactions – namely, locks that have been granted  Maintain information about any outstanding requests for data items – namely locks that have been requested but not granted yet. Deadlock Detection & Recovery:

 Activate an algorithm (periodically or when required) which uses the above information to determine whether the system has entered a deadlock state  If a deadlock state is entered (which may involve more than one deadlock), the system attempts to recover from the deadlock – namely, breaking the deadlock. Deadlock Detection & Recovery:

 A Wait For Graph (WFG) can be used to detect a deadlock – a graph of ‘who is waiting for whom’.  WFG is a direct graph G = (N,E) which consists of a set of nodes N and a set of edges E  Create a node for each transaction  Create a directed edge Ti  Tj, if transaction Ti is waiting to lock an item which currently locked by Tj  When Tj releases the lock(s) on the items which Ti was waiting for, the directed edge is removed from the graph  Deadlock exists if and only if the WFG contains a cycle Deadlock Detection – WFG:

No Deadlock Yes Deadlock Deadlock Detection – WFG:

 The question of when and how often the detection algorithm (e.g. WFG) should be invoked into action depends on several factors, including  The number of transactions running in the system  The waiting time of transactions  The frequency of deadlock occurrences  etc. Timing for Detection:

 Assumption:  The following list represents the sequence of event in an interleaved execution of a set of transactions T1, T2, … T7 in a concurrency system based on locking, where A, B, …. F are data items.  Assume that FETCH A acquires an S lock on A, UPDATE A promotes that lock to an X lock, and all locks are held to the next synchpoint  Question: Provide a Wait–for–Graph to determine whether there is a deadlock at time t17 and if so how the system could recover from the deadlock. A working example of WFG:

 After a deadlock situation has been identified, the system must try to recover from it.  The most common solution is to rollback one or more transactions involved in the deadlock, so that deadlock can be broken  Three issues to be addressed in deadlock recovery  Issue of choosing a victim  Issue of rollback operation  Issue of Starvation Deadlock Recovery:

1. Issue of choosing a victim  Determine which transaction(s), among a set of deadlocked transactions, to be rolled back in order to break the deadlock. Criteria for choosing such a victim transaction often depends on cost factors. 2. Issue of Rollback operation  Determine how far the chosen victim transaction should be rolled back (total rollback or partial rollback) Deadlock Recovery – 3 Issues:

3. Issue of starvation  Avoid situations where some transaction may always be chosen as the victim due to cost factors based selection, hence never completing its job. Deadlock Recovery – 3 Issues:

Thank you!!! Questions are WELCOME Academic Year 2014 Spring Academic Year 2014 Spring