C ONCURRENCY C ONTROL ON R ELATIONAL D ATABASES Seminar: Transaction Processing (Bachelor) SS 2009 Dennis Stratmann.

Slides:



Advertisements
Similar presentations
Cs4432concurrency control1 CS4432: Database Systems II Lecture #21 Concurrency Control : Theory Professor Elke A. Rundensteiner.
Advertisements

Database Systems (資料庫系統)
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.
Accessing data Transactions. Agenda Questions from last class? Transactions concurrency Locking rollback.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Chapter 15: Transactions Transaction Concept Transaction Concept Concurrent Executions Concurrent Executions Serializability Serializability Testing for.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control: Locking-based Protocols Professor Elke A. Rundensteiner.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
Concurrency Control Part 2 R&G - Chapter 17 The sequel was far better than the original! -- Nobody.
Kyoung-Hwan Yun (#110). Conflicts Precedence Graphs and a Test for Conflict- Serializability.
1 CS216 Advanced Database Systems Shivnath Babu Notes 11: Concurrency Control.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. –Because disk accesses are.
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.
Transaction Processing: Concurrency and Serializability 10/4/05.
6/27/2015Transactional Information Systems8-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
Transactions Amol Deshpande CMSC424. Today Project stuff… Summer Internships 
CS4432transaction management1 CS4432: Database Systems II Lecture #23 Transaction Management Professor Elke A. Rundensteiner.
BACS 485—Database Management Concurrency Control Overview of Database Concurrency Control.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
©Silberschatz, Korth and Sudarshan6.1Database System Concepts Chapter 6: Integrity and Security Domain Constraints Referential Integrity Assertions Triggers.
CIS 720 Concurrency Control. Locking Atomic statement –Can be used to perform two or more updates atomically Th1: …. ;……. Th2:…………. ;…….
08_Transactions_LECTURE2 DBMSs should guarantee ACID properties (Atomicity, Consistency, Isolation, Durability). This is typically done by guaranteeing.
Transactions Sylvia Huang CS 157B. Transaction A transaction is a unit of program execution that accesses and possibly updates various data items. A transaction.
DB Transactions CS143 Notes TRANSACTION: A sequence of SQL statements that are executed "together" as one unit:
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Department of Computer Science and Engineering, HKUST 1 More on Isolation.
Database Systems/COMP4910/Spring05/Melikyan1 Transaction Management Overview Unit 2 Chapter 16.
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
Sekolah Tinggi Ilmu Statistik (STIS) 1 Dr. Said Mirza Pahlevi, M.Eng.
A New Basis for the SQL Isolation Level Standard Atul Adya: Microsoft Research Barbara Liskov: LCS, MIT Patrick O’ Neil: Univ. Of Mass., Boston.
Chapter 15: Transactions Loc Hoang CS 157B. Definition n A transaction is a discrete unit of work that must be completely processed or not processed at.
Classification of Weak Correctness Criteria for Real-Time Database Applications Lee, Kyu-Woong and Park, Seog Sogang Univ., Seoul, Korea.
Degrees of Isolation – A Theoretical Formulation Presented by Balaji Sethuraman.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
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.
D ATABASE A DMINISTRATION L ECTURE N O 5 Muhammad Abrar.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
1 Database Systems ( 資料庫系統 ) December 27, 2004 Chapter 17 By Hao-hua Chu ( 朱浩華 )
1 CSE232A: Database System Principles More Concurrency Control and Transaction Processing.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
1 Controlled concurrency Now we start looking at what kind of concurrency we should allow We first look at uncontrolled concurrency and see what happens.
Parallel Data Structures. Story so far Wirth’s motto –Algorithm + Data structure = Program So far, we have studied –parallelism in regular and irregular.
6/18/2016Transactional Information Systems3-1 Part II: Concurrency Control 3 Concurrency Control: Notions of Correctness for the Page Model 4 Concurrency.
Chapter 8: Concurrency Control on Relational Databases
Chapter 6: Integrity (and Security)
8. Concurrency Control on Relational Database
Transaction Management
CS216: Data-Intensive Computing Systems
CSIS 7102 Spring 2004 Lecture 2 : Serializability
Transactions.
Temple University – CIS Dept. CIS661 – Principles of Data Management
CIS 720 Concurrency Control.
Transactions Sylvia Huang CS 157B.
Module 17: Transactions.
Transaction Management Overview
Transaction management
C. Faloutsos Transactions
Temple University – CIS Dept. CIS616– Principles of Data Management
Transation Management
UNIT -IV Transaction.
Module 17: Transactions.
Database Systems (資料庫系統)
Module 17: Transactions.
Outline Introduction Background Distributed DBMS Architecture
Temple University – CIS Dept. CIS661 – Principles of Data Management
Presentation transcript:

C ONCURRENCY C ONTROL ON R ELATIONAL D ATABASES Seminar: Transaction Processing (Bachelor) SS 2009 Dennis Stratmann

O UTLINE Goal and Overview Examine Three Approaches to CC on RD: 1. Predicate-Oriented Concurrency Control 2. Relational Update Transactions Syntax and Semantics Histories and Final State Serializability Conflict Serializability Extended Conflict Serializability 3. Exploiting Transaction Program Knowledge Transaction Chopping Applicability of Chopping Summary Questions & Answers 2 Concurrency Control on Relational Databases

G OAL AND O VERVIEW 3 Concurrency Control on Relational Databases

G OAL AND O VERVIEW Semantic approach to Concurrency Control Possible to exploit semantic knowledge at higher abstraction level 4 Concurrency Control on Relational Databases

G OAL AND O VERVIEW Three Approaches to CC on RD: Predicate-Oriented Concurrency Control Relational Update Transactions Exploiting Transaction Program Knowledge 5 Concurrency Control on Relational Databases

T HREE A PPROACHES TO CC ON RD: 1. Predicate-Oriented Concurrency Control 6 Concurrency Control on Relational Databases

1. P REDICATE -O RIENTED CC ON RD Relational Database 7 Concurrency Control on Relational Databases

1. P REDICATE -O RIENTED CC ON RD Lock entire Relation 8 Concurrency Control on Relational Databases

1. P REDICATE -O RIENTED CC ON RD Lock individual Tuples 9 Concurrency Control on Relational Databases

1. P REDICATE -O RIENTED CC ON RD Concurrency Control on Relational Databases 10 Phantom Problem: Transaction 1: Transaction 2: DELETE FROM Emp WHERE Department = ‘Service’ AND Position = ‘Manager’ DELETE FROM Emp WHERE Department = ‘Service’ AND Position = ‘Manager’ INSERT INTO Emp VALUES (‘Smith’, ‘Service’, ‘Manager’, 40000) INSERT INTO Emp VALUES (‘Smith’, ‘Service’, ‘Manager’, 40000) SELECT Name, Position, Salary FROM Emp WHERE Department = ‘Service’ SELECT Name, Position, Salary FROM Emp WHERE Department = ‘Service’ UPDATE Emp SET Department = ‘Sales’ WHERE Department = ‘Service’ AND Position <> ‘Manager’ UPDATE Emp SET Department = ‘Sales’ WHERE Department = ‘Service’ AND Position <> ‘Manager’ INSERT INTO Emp VALUES (‘Sone’, ‘Serivce’, ‘Clerk’, 13000) INSERT INTO Emp VALUES (‘Sone’, ‘Serivce’, ‘Clerk’, 13000)

1. P REDICATE -O RIENTED CC ON RD Predicate Locking 11 Concurrency Control on Relational Databases

1. P REDICATE -O RIENTED CC ON RD Transaction 1: C a : Department = ‘Service‘ Position = ‘Manager‘ C b : Name = ‘Smith‘ Department = ‘Service‘ Position = ‘Manager‘ Salary = ‘40000‘ C c1 : Department = ‘Service‘ Position ‘Manager‘ C c2 : Department = ‘Sales‘ Position ‘Manager‘ C d : Name = ‘Stone‘ Department = ‘Service‘ Position = ‘Clerk‘ Salary = ‘13000‘ 12 Concurrency Control on Relational Databases DELETE FROM Emp WHERE Department = ‘Service’ AND Position = ‘Manager’ DELETE FROM Emp WHERE Department = ‘Service’ AND Position = ‘Manager’ INSERT INTO Emp VALUES (‘Smith’, ‘Service’, ‘Manager’, 40000) INSERT INTO Emp VALUES (‘Smith’, ‘Service’, ‘Manager’, 40000) UPDATE Emp SET Department = ‘Sales’ WHERE Department = ‘Service’ AND Position <> ‘Manager’ UPDATE Emp SET Department = ‘Sales’ WHERE Department = ‘Service’ AND Position <> ‘Manager’ INSERT INTO Emp VALUES (‘Sone’, ‘Serivce’, ‘Clerk’, 13000) INSERT INTO Emp VALUES (‘Sone’, ‘Serivce’, ‘Clerk’, 13000)

1. P REDICATE -O RIENTED CC ON RD Transaction 2: C q : Department = ‘Service‘ Transaction 3: C p : Department = ‘Sales‘ Example: H( C a ) H( C q ) ∅ H( C b ) H( C q ) ∅ H( C c1 ) H( C q ) ∅ H(C c2 ) H(C q ) = ∅ H(C d ) H(C q ) ∅ 13 Concurrency Control on Relational Databases SELECT Name, Position, Salary FROM Emp WHERE Department = ‘Service’ SELECT Name, Position, Salary FROM Emp WHERE Department = ‘Service’ SELECT Name, Position, Salary FROM Emp WHERE Department = ‘Sales’ SELECT Name, Position, Salary FROM Emp WHERE Department = ‘Sales’ H( C a ) H( C p ) = ∅ H( C b ) H( C p ) = ∅ H( C c1 ) H( C p ) = ∅ H( C c2 ) H( C p ) ∅ H(C d ) H(C p ) = ∅

1. P REDICATE -O RIENTED CC ON RD Scheduler 14 Concurrency Control on Relational Databases

T HREE A PPROACHES TO CC ON RD: 2. Relational Update Transactions 15 Concurrency Control on Relational Databases

2. R ELATIONAL U PDATE T RANSACTIONS S YNTAX AND S EMANTICS Concurrency Control on Relational Databases 16 IDM Transaction Model Insertion:i R (C) Deletion:d R (C) Modify:m R (C 1; C 2 ) Semantics is called effect

2. R ELATIONAL U PDATE T RANSACTIONS S YNTAX AND S EMANTICS Transaction Equivalence Two IDM Transactions t and t ’ are equivalent, if eff(t) = eff(t ’ ) Written: t t ’ Commutativity Rules Simplification Rules 17 Concurrency Control on Relational Databases

2. R ELATIONAL U PDATE T RANSACTIONS H ISTORIES AND F INAL S TATE S ERIALIZABILITY A history s is serial, if all Transactions appear strictly one after the other A history s is Final State Serializable if s s ’ for some history s ’ FSR IDM denotes class of all Final State Serializable histories 18 Concurrency Control on Relational Databases

2. R ELATIONAL U PDATE T RANSACTIONS H ISTORIES AND F INAL S TATE S ERIALIZABILITY Example: 19 Concurrency Control on Relational Databases t1 = d(3)m(1;2)m(3;4) t 2 = d(3)m(2;3) s = d2(3)d1(3)m 1 (1;2)m2(2;3)m1(3;4) s ’ = d(3)m(1;4)m(2;4)m(3;4)eff(s) = eff(s ’ ) s s ’

2. R ELATIONAL U PDATE T RANSACTIONS H ISTORIES AND F INAL S TATE S ERIALIZABILITY t1 = d(3)m(1;2)m(3;4) t 2 = d(3)m(2;3) s = d2(3)d1(3)m 1 (1;2)m2(2;3)m1(3;4)s / t1t2 or s / t2t1 s FSRIDMt1 t1‘ = d(3)m(1;2)s ‘ = d2(3)d1(3)m 1 (1;2)m2(2;3) t1t 2 20 Concurrency Control on Relational Databases

2. R ELATIONAL U PDATE T RANSACTIONS C ONFLICT S ERIALIZABILITY A history s for a set T of n transactions is conflict serializable, if s t p(1)...t p(n) using only the Commutativity Rules CSR IDM denotes class of all Conflict Serializable histories Conflict Graph G(s) = (T,E) History s CSR IDM, if G(s) is acyclic 21 Concurrency Control on Relational Databases

2. R ELATIONAL U PDATE T RANSACTIONS C ONFLICT S ERIALIZABILITY Consider s = m 2 (1;2) m 1 (2;3) m 2 (3;2) G(s) is cyclic, so s is not in CSR IDM On the other hand, s  m 1 (2;3) m 2 (1;2) m 2 (3;2)  t 1 t 2 s is in FSR IDM CSR IDM FSR IDM 22 Concurrency Control on Relational Databases t1t1 t2t2

2. R ELATIONAL U PDATE T RANSACTIONS E XTENDED C ONFLICT S ERIALIZABILITY Sometimes, the context in which a conflict occurs can make a difference: Example : Let s = d 1 (0) m 1 (0;1) m 2 (1;2) m 1 (2;3) G(s) is cyclic, but s  m 2 (1;2) d 1 (0) m 1 (0;1) m 1 (2;3)  t 2 t 1 Intuitively the conflict involving m 1 (0;1) does not exist (due to d 1 (0) ) ! A history s for a set T of n transactions is extended conflict serializable, if Extended Conflict Graph EG(s) = (T,E) is acyclic ECSR IDM denotes class of all Extended Conflict Serializable histories 23 Concurrency Control on Relational Databases

2. R ELATIONAL U PDATE T RANSACTIONS E XTENDED C ONFLICT S ERIALIZABILITY CSR IDM ECSR IDM FSR IDM 24 Concurrency Control on Relational Databases FSRIDM ECSRIDM CSRIDM

T HREE A PPROACHES TO CC ON RD: 3. Exploiting Transaction Program Knowledge 25 Concurrency Control on Relational Databases

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE 26 Concurrency Control on Relational Databases

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE T RANSACTION C HOPPING Transaction Chopping Short Transactions need less locks Short Transactions cause potentially less lock contention Chopping depends on concurrent Transactions 27 Concurrency Control on Relational Databases

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE T RANSACTION C HOPPING Definition of Transaction Chopping Every database operation invoked by the chopped transactions is contained in exactly one piece, and the order of operation invocations is preserved 28 Concurrency Control on Relational Databases

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE T RANSACTION C HOPPING Deadlock / Rollback situation Atomicity of original Transaction needs to be preserved 29 Concurrency Control on Relational Databases

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE T RANSACTION C HOPPING Concurrency Control on Relational Databases 30 Three types of Transactions: 1. A Transaction updating a single Customer’s Account as well as the corresponding Branch 2. A Transaction reading a Customer’s Account Balance 3. A Transaction comparing the grand Total of all Account Balances with the Sum of the Branch Balances

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE T RANSACTION C HOPPING t 1 = r 1 (A 1 )w 1 (A 1 )r 1 (B 1 )w 1 (B 1 ) t 2 = r 2 (A 3 )w 2 (A 3 )r 2 (B 1 )w 2 (B 1 ) t 3 = r 3 (A 4 )w 3 (A 4 )r 3 (B 2 )w 3 (B 2 ) t 4 = r 4 (A 2 ) t 5 = r 5 (A 4 ) t 6 = r 6 (A 1 )r 6 (A 2 )r 6 (A 3 )r 6 (B 1 )r 6 (A 4 )r 6 (A 5 )r 6 (B 2 ) 31 Concurrency Control on Relational Databases SELECT Balance INTO :oldbalance FROM Accounts WHERE AccountNo = A1; UPDATE Accounts SET Balance = :newbalance WHERE AccountNo = A1; SELECT Total INTO :oldtotal FROM Branches WHERE BranchNo = B1; UPDATE Branches SET TOTAL = :newtotal WHERE Branches = B1; SELECT Balance INTO :oldbalance FROM Accounts WHERE AccountNo = A1; UPDATE Accounts SET Balance = :newbalance WHERE AccountNo = A1; SELECT Total INTO :oldtotal FROM Branches WHERE BranchNo = B1; UPDATE Branches SET TOTAL = :newtotal WHERE Branches = B1;

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE T RANSACTION C HOPPING Test if a given chopping is correct with a Chopping Graph Example t 6 = r 6 (A 1 )r 6 (A 2 )r 6 (A 3 )r 6 (B 1 )r 6 (A 4 )r 6 (A 5 )r 6 (B 2 ) Chop into two pieces: t 61 = r 61 (A 1 )r 61 (A 2 )r 61 (A 3 )r 61 (B 1 ) t 62 = r 62 (A 4 )r 62 (A 5 )r 62 (B 2 ) Corresponding Chopping Graph: s: sibling c: conflict A chopping is correct if the associated graph does not contain an sc cycle. 32 Concurrency Control on Relational Databases

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE T RANSACTION C HOPPING Further in the example: t 1 = r 1 (A 1 )w 1 (A 1 )r 1 (B 1 )w 1 (B 1 ) Chop into two pieces: t 11 = r 1 (A 1 )w 1 (A 1 ) t 12 = r 1 (B 1 )w 1 (B 1 ) Corresponding Chopping Graph: Making chopping finer can introduce sc cycles 33 Concurrency Control on Relational Databases

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE A PPLICABILITY OF C HOPPING Applicability of Chopping To apply chopping algorithm, semantic knowledge is necessary Semantic knowledge derived form predicates Real World Example: High Level conflict Record-Level conflict 34 Concurrency Control on Relational Databases SELECT AccountNo, Balance FROM Accounts WHERE City = ‘Konstanz’ SELECT AccountNo, Balance FROM Accounts WHERE City = ‘Konstanz’ UPDATE Accounts SET Balance = Balance * 1.05 WHERE City = ‘Stuttgart’ UPDATE Accounts SET Balance = Balance * 1.05 WHERE City = ‘Stuttgart’

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE A PPLICABILITY OF C HOPPING Gain chopping relevant information from parameterized SQL statements: The chopping method is in limited settings ready for practical use, if No control-flow branching is used No loops are used No If-then-else constructs are used 35 Concurrency Control on Relational Databases SELECT AccountNo, Balance FROM Accounts WHERE AccountType = ‘savings’ AND City = :x SELECT AccountNo, Balance FROM Accounts WHERE AccountType = ‘savings’ AND City = :x UPDATE Accounts SET Balance = Balance * 1.05 WHERE AccountType = ‘checking’ AND City = :y UPDATE Accounts SET Balance = Balance * 1.05 WHERE AccountType = ‘checking’ AND City = :y

3. E XPLOITING T RANSACTION P ROGRAM K NOWLEDGE A PPLICABILITY OF C HOPPING Rewrite SQL statement to a parameter-less statement 36 Concurrency Control on Relational Databases SELECT AccountNo, Balance FROM Accounts WHERE AccountType = ‘savings’ AND City = :x; If not found then SELECT AccountNo, Balance FROM Accounts WHERE AccountTyoe = ‘checking’ AND City = :x; fi; SELECT AccountNo, Balance FROM Accounts WHERE AccountType = ‘savings’ AND City = :x; If not found then SELECT AccountNo, Balance FROM Accounts WHERE AccountTyoe = ‘checking’ AND City = :x; fi; SELECT AccountNo, Balance FROM Accounts WHERE AccountType = ‘savings’; SELECT AccountNo, Balance FROM Accounts WHERE AccountTyoe = ‘checking’; SELECT AccountNo, Balance FROM Accounts WHERE AccountType = ‘savings’; SELECT AccountNo, Balance FROM Accounts WHERE AccountTyoe = ‘checking’;

S UMMARY 37 Concurrency Control on Relational Databases

S UMMARY Predicate-Oriented Concurrency Control Trade-off between locking entire relation and locking individual tuples NP complete to test Satisfiability Relational Update Transactions Commutativity based Serializability ( FSR IDM ) Conflict Serializability ([ E ] CSR IDM ) Exploiting Transaction Program Knowledge Decomposition of Transactions into small pieces Only in limited settings ready for practical use 38 Concurrency Control on Relational Databases

T HANKS FOR LISTENING 39 Concurrency Control on Relational Databases

Q UESTIONS & A NSWERS 40 Concurrency Control on Relational Databases