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

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

Universität Karlsruhe (TH) TAV 10© 2007 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. Böhm Chapter 10 Distributed Transactions: Synchronization.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Data recovery 1. 2 Recovery - introduction recovery restoring a system, after an error or failure, to a state that was previously known as correct have.
1 Term 2, 2004, Lecture 6, TransactionsMarian Ursu, Department of Computing, Goldsmiths College Transactions 3.
Transaction Management Reading: CB, Ch. 22. Dept of Computing Science, University of Aberdeen2 In this lecture you will learn the problems of concurrency.
Dr Alwyn Barry Dr Joanna Bryson
CM20145 Transactions & Serializability
Concurrency Control Alexandra Cristea and Steve Russ 1.
CSL 771: Database Implementation Transaction Processing
Concurrency Control Techniques
ABC Technology Project
Squares and Square Root WALK. Solve each problem REVIEW:
Lecture plan Transaction processing Concurrency control
Indra Budi Transaction Indra Budi
Chapter 5 Test Review Sections 5-1 through 5-4.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Addition 1’s to 20.
25 seconds left…...
Week 1.
We will resume in: 25 Minutes.
Concurrency Control WXES 2103 Database. Content Concurrency Problems Concurrency Control Concurrency Control Approaches.
Unit 9 Concurrency Control. 9-2 Wei-Pang Yang, Information Management, NDHU Content  9.1 Introduction  9.2 Locking Technique  9.3 Optimistic Concurrency.
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.
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
CSC271 Database Systems Lecture # 32.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
Sekolah Tinggi Ilmu Statistik (STIS) 1 Dr. Said Mirza Pahlevi, M.Eng.
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management
©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.
Academic Year 2014 Spring Academic Year 2014 Spring.
PMIT-6102 Advanced Database Systems
V. Megalooikonomou Concurrency control (based on slides by C. Faloutsos at CMU and on notes by Silberchatz,Korth, and Sudarshan) Temple University – CIS.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Concurrency control.
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.
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.
1 Lecture 4: Transaction Serialization and Concurrency Control Advanced Databases CG096 Nick Rossiter [Emma-Jane Phillips-Tait]
Switch off your Mobiles Phones or Change Profile to Silent Mode.
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.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Concurrency Control.
Transaction Properties
Unit :- 1 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
STRUCTURE OF PRESENTATION :
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.
Concurrency Unit 4.2 Dr Gordon Russell, Napier University
Presentation transcript:

Concurrency control 1

2 Introduction concurrency more than one transaction have access to data simultaneously part of transaction processing

Concurrency control 3 Outline motivation three concurrency problems criterion for correctness of concurrent transactions serialisability two-phase locking protocol locking problems deadlocks

Concurrency control 4 Three concurrency problems the lost update the uncommitted dependency the inconsistent analysis

Concurrency control 5 The lost update problem Transaction Atime Transaction B RETRIEVE pt1 t2 RETRIEVE p UPDATE pt3 t4 UPDATE p

Concurrency control 6 The uncommitted dependency problem Transaction Atime Transaction B t1 UPDATE p RETRIEVE pt2 t3 ROLLBACK

Concurrency control 7 The uncommitted dependency problem Transaction Atime Transaction B t1 UPDATE p UPDATE pt2 t3 ROLLBACK

Concurrency control 8 The inconsistent analysis problem

Concurrency control 9 Issue all these problems may lead to an inconsistent (incorrect) database is there a criterion based on which to decide weather a certain set of transaction, if executed concurrently, leads to an incorrect database or not?

Concurrency control 10 Serialisability criterion for correctness for concurrent execution of transactions: the interleaved execution of a set of transactions is guaranteed to be correct if it is serialisable correct the DB is not in an inconsistent state serialisability: an interleaved execution has the same result as some serial execution

Concurrency control 11 Terminology schedule any execution of a set of transactions serial / interleaved schedule equivalent schedules produce the same result independent of the initial state of the DB

Concurrency control 12 Serialisable schedule

Concurrency control 13 Notes the schedules described in the problem examples were not serialisable neither A-then-B nor B-then-A two different interleaved transactions might produce different results, yet both can be considered correct example

Concurrency control 14 Two phase locking theorem if all transactions obey the two phase locking protocol then all possible interleaved schedules are serialisable

Concurrency control 15 Two phase locking protocol 1.before operating on an object a transaction must acquire a lock on that object 2.after releasing a lock a transaction must not go on to acquire any more locks phase1 (growing): acquire locks (not simultaneously) phase2 (shrinking): release locks (no further acquisitions allowed) usually locks are released by the COMMIT or ROLLBACK operation in practice trade-off between release lock early and acquire more locks and the two phase locking protocol

Concurrency control 16 Locking applicable to tuples types X, exclusive - write S, shared - read rules compatibility matrix

Concurrency control 17 Compatibility matrix

Concurrency control 18 Data access protocol retrieve tuple acquire S lock (on that tuple) update tuple acquire X lock (on that tuple), or promote the S lock it holds (if it holds one) implicit request if request for lock is denied transaction goes in wait state until the lock is released livelock - first come first served X locks are held until end of transaction (COMMIT or ROLLBACK) (two phase locking protocol)

Concurrency control 19 The uncommitted dependency problem : OK Transaction AtimeTransaction B t1UPDATE p (X lock on p) RETRIEVE pt2 (request X lock on p) waitt3COMMIT / ROLL.. wait(release X lock on p) resume RETRIEVE pt4 (acquire S lock on p)

Concurrency control 20 The lost update problem : dead-lock Transaction A time Transaction B RETRIEVE p t1 (acquire S lock on p) t2 RETRIEVE p (acquire S lock on p) UPDATE p t3 (request X lock on p denied) t4 UPDATE p wait (request X lock on p wait denied) wait wait

Concurrency control 21 Exercises check what happens in the other uncommitted problem the inconsistent analysis problem the inconsistent analysis problem - example from Date p. 399 (!there is a little mistake!)

Concurrency control 22 Locking solves the three basic problems of concurrency theorem if all the transactions of a set S of transactions comply with the two phase locking protocol, then all their possible interleaved executions (schedules) are serialisable however, not all schedules produce the same result think of examples introduces another problem: deadlock

Concurrency control 23 Deadlock Transaction Atime Transaction B acquire LOCK p1 EXCLUSIVE t1 t2 acquire LOCK p2 EXCLUSIVE request LOCK p2 EXCLUSIVE t3 wait wait t4 request LOCK p1 EXCLUSIVEwait

Concurrency control 24 Deadlock two or more transaction are waiting for the other to release a lock in practice: usually two transactions detect a deadlock cycle in the wait-for graph, or timing mechanism break a deadlock rollback a victim transaction what happens to the victim?

Concurrency control 25 Further topics two phase locking protocol - not feasible in practice (not efficient) levels of isolation degree of interference intent locking locking granularity SQL support no explicit locking facilities it supports different isolation levels (with locking behind the scenes)