Concurrency Control Nate Nystrom CS 632 February 6, 2001.

Slides:



Advertisements
Similar presentations
Concurrency Control III. General Overview Relational model - SQL Formal & commercial query languages Functional Dependencies Normalization Physical Design.
Advertisements

Optimistic Methods for Concurrency Control By : H.T. Kung & John T. Robinson Presenters: Munawer Saeed.
Unit 9 Concurrency Control. 9-2 Wei-Pang Yang, Information Management, NDHU Content  9.1 Introduction  9.2 Locking Technique  9.3 Optimistic Concurrency.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Transaction Management and Concurrency Control
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.
1 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
University of Tampere, CS Department Distributed Transaction Management Jyrki Nummenmaa
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Principles of Transaction Management. Outline Transaction concepts & protocols Performance impact of concurrency control Performance tuning.
Concurrency Control II
Presented by Dr. Greg Speegle.  Concurrency Control  Multiple Versions  Version number timestamp of writing transaction  Read last committed value.
Concurrency Control Part 2 R&G - Chapter 17 The sequel was far better than the original! -- Nobody.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
1 Supplemental Notes: Practical Aspects of Transactions THIS MATERIAL IS OPTIONAL.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. –Because disk accesses are.
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
Quick Review of May 1 material Concurrent Execution and Serializability –inconsistent concurrent schedules –transaction conflicts serializable == conflict.
Transaction Management and Concurrency Control
Transactions – T4.3 Title: Concurrency Control Performance Modeling: Alternatives and Implications Authors: R. Agarwal, M. J. Carey, M. Livny ACM TODS,
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
What is a Transaction? Logical unit of work
Transaction Processing: Concurrency and Serializability 10/4/05.
Transaction Management
Concurrency Control John Ortiz.
Concurrency Control R &G - Chapter 19 Smile, it is the key that fits the lock of everybody's heart. Anthony J. D'Angelo, The College Blue Book.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Alternative Concurrency Control Methods R&G - Chapter 17.
DBMS2001Notes 9: Transaction Processing1 Principles of Database Management Systems 9: More on Transaction Processing Pekka Kilpeläinen (Partially based.
Transactions and concurrency control
1 Transaction Management Overview Chapter Transactions  A transaction is the DBMS’s abstract view of a user program: a sequence of reads and writes.
School of Information Technologies Michael Cahill 1, Uwe Röhm and Alan Fekete School of IT, University of Sydney {mjc, roehm, Serializable.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Database Systems/COMP4910/Spring05/Melikyan1 Transaction Management Overview Unit 2 Chapter 16.
Concurrency Server accesses data on behalf of client – series of operations is a transaction – transactions are atomic Several clients may invoke transactions.
1 Concurrency Control II: Locking and Isolation Levels.
Chapter 16 Concurrency. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.16-2 Topics in this Chapter Three Concurrency Problems Locking Deadlock.
A New Basis for the SQL Isolation Level Standard Atul Adya: Microsoft Research Barbara Liskov: LCS, MIT Patrick O’ Neil: Univ. Of Mass., Boston.
Optimistic Methods for Concurrency Control By: H.T. Kung and John Robinson Presented by: Frederick Ramirez.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Chapter 20 Transaction Management Thomas Connolly, Carolyn Begg, Database System, A Practical Approach to Design Implementation and Management, 4 th Edition,
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
1 CSE232A: Database System Principles More Concurrency Control and Transaction Processing.
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
Database Isolation Levels. Reading Database Isolation Levels, lecture notes by Dr. A. Fekete, resentation/AustralianComputer.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
MULTIUSER DATABASES : Concurrency and Transaction Management.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
1 Concurrency Control. 2 Why Have Concurrent Processes? v Better transaction throughput, response time v Done via better utilization of resources: –While.
Concurrency Control Techniques
Transaction Management and Concurrency Control
Transaction Management
Concurrency Control via Validation
March 21st – Transactions
Transaction Management Overview
Transaction Management
11/29/2018.
Concurrency.
Chapter 10 Transaction Management and Concurrency Control
Concurrency Control by Validation
Distributed Transactions
Transaction management
Transactions and Concurrency
Transaction Management
Presentation transcript:

Concurrency Control Nate Nystrom CS 632 February 6, 2001

Papers  Berenson, Bernstein, Gray, et al., "A Critique of ANSI SQL Isolation Levels", SIGMOD'95  Kung and Robinson, "On Optimistic Methods for Concurrency Control", TODS June 1981  Agrawal, Carey, and Livny, "Models for Studying Concurrency Control Performance: Alternatives and Implications", SIGMOD'85

Concurrency control methods  Locking  By far, the most popular method  Deadlock, starvation  Optimistic  High abort rates  Immediate restart

Isolation Levels  Serializability is expensive to enforce  Trade correctness for performance  Transactions can run at lower isolation levels  Repeatable read  Read committed  Read uncommitted

Basics  History: sequence of operations  Ex: r 1 (x) r 2 (y) w 1 (y) c 1 w 2 (x) a 2  Dependencies: wr (true), rw (anti), ww (output)  H and H' equivalent if H' is reordering of H and H' has same dependencies as H  H serializable if  serial H' s.t. H  H'  Concurrent T and T' conflict if both access same item and one writes

ANSI SQL Isolation Levels  Defined in terms of proscribed anomalies  Read Uncommitted - everything allowed  Read Committed - dirty reads  Repeatable Read - dirty reads, fuzzy reads  Serializable - dirty reads, fuzzy reads, phantoms

Problems  Anomalies are ambiguous  w 1 (x)... r 2 (x)... (a 1 & c 2 in any order)  w 1 (x)... r 2 (x)... ((c 1 | a 1 ) & (c 2 | a 2 ) in any order)  First case is strict interpretation (an anomaly), second is loose interpretation (a phenomenon)  Anomalies don't prevent some undesirable behavior  Ex: Phantom defined to include inserts and updates, but not deletes

Locking  T has well-formed writes (reads) if it requests a write lock before writing  T has two-phase locking if it does not request any lock after releasing a lock  Locks are long duration if held until abort, else short duration  Theorem: well-formed two-phase locking guarantees serializability

Locking Isolation Levels  0 has well-formed (i.e., short) writes  1  (read committed) - long duration write locks   (read uncommitted) - short read locks, long write locks  repeatable read - short predicate read locks, long item read locks, long write locks   (serializable) - long read locks, long write locks

Dirty Writes  ANSI definitions lack prohibition of dirty writes  w 1 (x)... w 2 (x)... ((c 1 | a 1 ) & (c 2 | a 2 ) in any order)  With dirty writes allowed, rollback is difficult to implement (with locking CC)  Prohibiting dirty writes serializes txns in write order (all ww dependencys go forward)

New Definitions  Use loose interpretation  Fix definition of phantom to prevent deletes  Prohibit dirty writes  Read Uncommitted - dirty writes  Read Committed - dirty writes, dirty reads  Repeatable Read - dirty writes, dirty reads, fuzzy reads  Serializable - dirty writes, dirty reads, fuzzy reads, phantoms

More Problems  New definitions are too strong  Prohibits some serializable histories  r 1 (x) w 1 (x) r 1 (y) w 1 (y) r 2 (x) r 2 (y) c 1 c 2  T 2 has dirty reads according to the proposed new definitions  Prohibiting dirty writes useful for recovery with locking CC, but not helpful for optimistic CC

Other Isolation Levels  Cursor stability  Prevent lost updates by adding cursor reads  Stronger than read committed  Weaker than repeatable read  Snapshot isolation  Read from/write to a snapshot of the committed data as of the time the transaction started  Stronger than read committed  Incomparable to repeatable read

Optimistic Concurrency Control  Divide transaction into read, validate, and write phases  Validation checks if transaction can be inserted into a serializable history  Why: lower message cost, little blocking in low contention environments, no deadlock  Why not: abort rates can be high, not suitable for interactive, non-restartable, transactions

Validation  Assign transaction i a unique number t(i).  Validation condition:  For all i and for all j with t(i) < t(j), one of the following must hold: 1 i completes write phase before j starts read phase 2 i completes write phase before j starts write phase and WS(i)  RS(j) =  3 i completes read phase before j completes read phase and WS(i)  (RS(j)  WS(j)) = 

Validation readwritevalidate readwritevalidate readwritevalidate readwritevalidate readwritevalidate readwritevalidate WS(i)  RS(j) =  i j WS(i)  (RS(j)  WS(j)) =  i i j j

Transaction numbers  What should t(i) be?  Unique timestamp assigned at beginning of validation phase  Guarantees that i completes read phase before j completes read phase if t(i) < t(j)

Serial Implementation  Ensure one of conditions (1) or (2) holds  At transaction begin, record start tn  At transaction end, record finish tn  Validate against all t in [start tn+1, finish tn] by checking if RS intersects WS(t)  (2) requires concurrent transactions write phases are serial: put validation, assignment of tn, and write phase in a critical section  Various optimizations to reduce size of critical section

Parallel Implementation  Ensure one of (1), (2), and (3) hold  At transaction end, take snapshot of active set, then add tid to active set  Validate outside CS against:  All t in [start tn+1, finish tn] by checking if RS intersects WS(t)  All t in our snapshot of active by checking if RS or WS intersects WS(t)  If valid, perform writes outside CS, assign tn, and remove from active set

Performance  Agrawal: previous studies flawed  Different performance models  contradictions  Flawed assumptions  Infinite resources  Transactions progress at a rate independent of number of concurrent transactions  Need a more complete, more realistic model

Logical Queuing Model terminals blocked Q ready Q update Q update delay object Q think?more? think object UPDATE COMMIT RESTART ACCESS BLOCK CC

Experiments  Compare locking, optimistic, and immediate-restart CC  Low contention (large database)  Infinite resources  Limited resources (small database)  Multiple resources  Interactive workloads

Throughput

Limited Resources  Correspondence between disk utilization and throughput when low contention  When high contention, correspondence between useful disk utilization and throughput  High contention  aborts and restarts

Response Time

Multiple Resources

 As resources increase, non-blocking CC scales better than blocking  Blocking CC thrashes waiting for locks  Optimistic CC thrashes on restarts  Immediate-restart CC reaches a plateau due to adaptive restart delay

Conclusions  Locking has better throughput for medium to high contention environments  If resource utilization low enough that waste can be tolerated, immediate- restart and optimistic CC have better throughput  Limit multiprogramming level to avoid thrashing due to blocking and restarts