Concurrency Chapter 6.2 V3.1 Napier University Dr Gordon Russell.

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.
Transactions Chapter 6.1 V3.1 Napier University Dr Gordon Russell.
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.
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.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
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 Transaction Management Database recovery Concurrency control.
©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)
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.
Concurrency Control Concurrency Control By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
1 Transactions Chapter Transactions A transaction is: a logical unit of work a sequence of steps to accomplish a single task Can have multiple.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
1 Concurrency Control II: Locking and Isolation Levels.
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.
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.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
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.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Transaction Management and Concurrency Control
Concurrency Control.
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
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Concurrency Unit 4.2 Dr Gordon Russell, Napier University
Transactions, Properties of Transactions
Presentation transcript:

Concurrency Chapter 6.2 V3.1 Napier University Dr Gordon Russell

Locking A solution to enforcing serialisability? read (shareable) lock write (exclusive) lock coarse granularity –easier processing –less concurrency fine granularity –more processing –higher 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.

Locking – Uncommitted Dependency Locking solves the uncommitted dependency problem TimeTransaction ATransaction BLock on R Before => after t1write(p,R)- => X t2read(R) WAIT t3 … WAIT … ABORTX => - t4read(R) GO- -> S

Deadlock Deadlock can arise when locks are used, and causes all related transactions to WAIT forever TimeTransaction ATransaction BLock State XY t1write(p,X)- => X- t2write(q,Y)X- => X t3read(Y) WAITXX t4 … WAIT … read(X) WAITXX t5 … WAIT … XX

Deadlock cont … The `lost update ’ senario results in deadlock with locks. So does the `inconsistency ’ scenario. TimeTransaction ATransaction BLock on R Before => after t1read(R)- => S t2read(R)S => S t3write(p,R)S t4 … WAIT … write(q,R)S t5 … WAIT … S

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 the transaction is not blocked on the first transaction, either directly or indirectly via another transaction.

Deadlock Resolution If a set of transactions is considered to be deadlocked: 1.choose a victim (e.g. the shortest-lived transaction) 2.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.

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 benefit of locking is lost. If all transactions obey the ‘ two-phase locking protocol ’, then all possible interleaved executions are guaranteed serialisable.

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 ’.

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 is equivalent to a particular serial order - the order of the timestamps.

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 read from 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 ’.