Concurrency Unit 4.2 Dr Gordon Russell, Napier University

Slides:



Advertisements
Similar presentations
Concurrency control 1. 2 Introduction concurrency more than one transaction have access to data simultaneously part of transaction processing.
Advertisements

1 Term 2, 2004, Lecture 6, TransactionsMarian Ursu, Department of Computing, Goldsmiths College Transactions 3.
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 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
Principles of Transaction Management. Outline Transaction concepts & protocols Performance impact of concurrency control Performance tuning.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
Lock-Based Concurrency Control
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
1 Data Concurrency David Konopnicki 1997 Revised by Mordo Shalom 2004.
Quick Review of Apr 29 material
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Processing: Concurrency and Serializability 10/4/05.
Transaction Management
1 Minggu 8, Pertemuan 15 Transaction Management Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Academic Year 2014 Spring Academic Year 2014 Spring.
Concurrency Control.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Databases Illuminated
PMIT-6102 Advanced Database Systems
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
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)
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.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
Chapter 16 Concurrency. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.16-2 Topics in this Chapter Three Concurrency Problems Locking Deadlock.
Concurrency Chapter 6.2 V3.1 Napier University Dr Gordon Russell.
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
1 CSE 480: Database Systems Lecture 24: Concurrency Control.
Timestamp-based Concurrency Control
1 Lecture 4: Transaction Serialization and Concurrency Control Advanced Databases CG096 Nick Rossiter [Emma-Jane Phillips-Tait]
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.
Lecture 8 Transactions & Concurrency UFCE8K-15-M: Data Management.
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.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Concurrency Control 2004, Spring Pusan National University Ki-Joune Li.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15 : Concurrency.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Lecture 3 Concurrency control techniques
Transaction Management and Concurrency Control
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 16: Concurrency Control
Transaction Properties
Chapter 16: Concurrency Control
4. Concurrency control techniques
Concurrency.
Chapter 10 Transaction Management and Concurrency Control
Concurrency Control WXES 2103 Database.
Chapter 15 : Concurrency Control
Concurrency Unit 4.2 Dr Gordon Russell, Napier University
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Temple University – CIS Dept. CIS661 – Principles of Data Management
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:

Concurrency Unit 4.2 Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Locking A solution to enforcing serialisability? read (shareable) lock write (exclusive) lock coarse granularity easier processing less concurrency fine granularity more processing higher concurrency Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Locking cont... Many systems use locking mechanisms for concurrency control. When a transaction needs an assurance that some object will not change in some unpredictable manner, it acquires a lock on that object. A transaction holding a read lock is permitted to read an object but not to change it. More than one transaction can hold a read lock for the same object. Usually, only one transaction may hold a write lock on an object. On a transaction schedule, we use ‘S’ to indicate a shared lock, and ‘X’ for an exclusive write lock. Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Locking – Uncommitted Dependency Locking solves the uncommitted dependency problem Time Transaction A Transaction B Lock on R Before => after t1 write(R) - => X t2 read(r) WAIT t3 …WAIT… ABORT X => - t4 read(r) GO - -> S Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Deadlock Deadlock can arise when locks are used, and causes all related transactions to WAIT forever Time Transaction A Transaction B Lock State X Y t1 write(X) - => X - t2 write(Y) t3 read(Y) WAIT t4 …WAIT… read(X) WAIT t5 Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Deadlock cont… The `lost update’ senario results in deadlock with locks. So does the `inconsistency’ scenario. Time Transaction A Transaction B Lock on R Before => after t1 read(r) - => S t2 S => S t3 write(R) S t4 …WAIT… t5 Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Deadlock Handling Deadlock avoidance pre-claim strategy used in operating systems not effective in database environments. Deadlock detection whenever a lock requests a wait, or on some perodic basis. if a transaction is blocked due to another transaction, make sure that that transaction is not blocked on the first transaction, either directly or indirectly via another transaction. Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Deadlock Resolution If a set of transactions is considered to be deadlocked: choose a victim (e.g. the shortest-lived transaction) rollback ‘victim’ transaction and restart it. The rollback terminates the transaction, undoing all its updates and releasing all of its locks. A message is passed to the victim and depending on the system the transaction may or may not be started again automatically. Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Two-Phase Locking The presence of locks does not guarantee serialisability. If a transaction is allowed to release locks before the transaction has completed, and is also allowed to acquire more (or even the same) locks later then the benifit or locking is lost. If all transactions obey the ‘two-phase locking protocol’, then all possible interleaved executions are guarenteed serialisable. Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Two-Phase locking cont... The two-phase locking protocol: Before operating on any item, a transaction must acquire at least a shared lock on that item. Thus no item can be accessed without first obtaining the correct lock. After releasing a lock, a transaction must never go on to acquire any more locks. The technical names for the two phases of the locking protocol are the ‘lock-acquisition phase’ and the ‘lock-release phase’. Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Other Database Consistency Methods Two-phase locking is not the only approach to enforcing database consistency. Another method used in some DMBS is timestamping. With timestamping, there are no locks to prevent transactions seeing uncommitted changes, and all physical updates are deferred to commit time. locking synchronises the interleaved execution of a set of transactions in such a way that it is equivalent to some serial execution of those transactions. timestamping synchronises that interleaved execution in such a way that it isequivalent to a particular serial order - the order of the timestamps. Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency

Timestamping rules The following rules are checked when transaction T attempts to change a data item. If the rule indicates ABORT, then transaction T is rolled back and aborted (and perhaps restarted). If T attempts to read a data item which has already been written to by a younger transaction then ABORT T. If T attempts to write a data item which has been seen or written to by a younger transaction then ABORT T. If transaction T aborts, then all other transactions which have seen a data item written to by T must also abort. In addition, other aborting transactions can cause further aborts on other transactions. This is a ‘cascading rollback’. Dr Gordon Russell, Copyright @ Napier University Unit 4.2 - Concurrency