Chapter 8: Concurrency Control on Relational Databases

Slides:



Advertisements
Similar presentations
Universität Karlsruhe (TH) TAV 10© 2007 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. Böhm Chapter 10 Distributed Transactions: Synchronization.
Advertisements

Cs4432concurrency control1 CS4432: Database Systems II Lecture #21 Concurrency Control : Theory Professor Elke A. Rundensteiner.
Database Systems (資料庫系統)
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 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 Professor Elke A. Rundensteiner.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #23 Concurrency Control Professor Elke A. Rundensteiner.
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.
C ONCURRENCY C ONTROL ON R ELATIONAL D ATABASES Seminar: Transaction Processing (Bachelor) SS 2009 Dennis Stratmann.
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.
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.
Concurrency. Busy, busy, busy... In production environments, it is unlikely that we can limit our system to just one user at a time. – Consequently, it.
Transaction Processing: Concurrency and Serializability 10/4/05.
Concurrency. Correctness Principle A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
6/27/2015Transactional Information Systems8-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
18.7 The Tree Protocol Andy Yang. Outline Introduction Motivation Rules for Access to Tree-Structured Data Why the Tree Protocol Works.
BACS 485—Database Management Concurrency Control Overview of Database Concurrency Control.
Transaction Management and Concurrency Control
1 Concurrency Control. 2 Transactions A transaction is a list of actions. The actions are reads (written R T (O)) and writes (written W T (O)) of database.
Chapter 181 Chapter 18: Concurrency Control (Slides by Hector Garcia-Molina,
CS 162 Discussion Section Week 9 11/11 – 11/15. Today’s Section ●Project discussion (5 min) ●Quiz (10 min) ●Lecture Review (20 min) ●Worksheet and Discussion.
Department of Computer Science and Engineering, HKUST 1 More on Isolation.
1 Concurrency Control II: Locking and Isolation Levels.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 136 Database Systems I SQL Modifications and Transactions.
©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.
Classification of Weak Correctness Criteria for Real-Time Database Applications Lee, Kyu-Woong and Park, Seog Sogang Univ., Seoul, Korea.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
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.
1 Database Systems ( 資料庫系統 ) December 27, 2004 Chapter 17 By Hao-hua Chu ( 朱浩華 )
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 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.
Jinze Liu. ACID Atomicity: TX’s are either completely done or not done at all Consistency: TX’s should leave the database in a consistent state Isolation:
6/18/2016Transactional Information Systems3-1 Part II: Concurrency Control 3 Concurrency Control: Notions of Correctness for the Page Model 4 Concurrency.
Contents. Goal and Overview. Ingredients. The Page Model.
8. Concurrency Control on Relational Database
Computational Models Database Lab Minji Jo.
Transaction Management and Concurrency Control
CS216: Data-Intensive Computing Systems
Concurrency Control.
CSIS 7102 Spring 2004 Lecture 2 : Serializability
Transactions.
March 21st – Transactions
Temple University – CIS Dept. CIS661 – Principles of Data Management
Concurrency.
Lecture 21: Concurrency & Locking
Chapter 15 : Concurrency Control
Lecture 22: Intro to Transactions & Logging IV
Transaction management
Transaction Management
Temple University – CIS Dept. CIS661 – Principles of Data Management
C. Faloutsos Transactions
Temple University – CIS Dept. CIS616– Principles of Data Management
Database Systems (資料庫系統)
Database Systems (資料庫系統)
Outline Introduction Background Distributed DBMS Architecture
Presentation transcript:

Chapter 8: Concurrency Control on Relational Databases 최병준

Outline Goal and Overview Examine Three Approaches to Concurrency Control on Relational Databases: 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 Concurrency Control on Relational Databases

Goal and Overview Semantic approach to Concurrency Control Possible to exploit semantic knowledge at higher abstraction level Three Approaches to Concurrency Control on Relational Databases Predicate-Oriented Concurrency Control Relational Update Transactions Exploiting Transaction Program Knowledge Hardly of practical relevance Efficient implementation is difficult to achieve Semantics is more complex than syntax Concurrency Control on Relational Databases

1. Predicate-Oriented Concurrency Control Relational Databases Database consists of tables Relation (r) : table Schema (R) : table header Attributes (A1, A2, … , An) : columns Finite domain dom(Ai) Tuples : elements of r ⊆ dom(A1) x … dom(An) Operations on tables and databases are Queries (select-from-where expressions) Insertions Deletions Modifications Two Locking for transactional access on relational database Lock entire relations Prevents simultaneously accessing an subset of tuples from relation, unnecessary delays Lock individual tuples Large number of locks may result (lock administration problem, phantom problem) Concurrency Control on Relational Databases

1. Predicate-Oriented Concurrency Control Phantom problem Example 8.1 Update transaction t: (a) Delete From Emp Where Department = ‘Service’ And Position = ‘Manager’ (b) Insert Into Emp Values (‘Smith’, ‘Service’, ‘Manager’, 40000) (c) Update Emp Set Department = ‘Sales’ Where Department = ‘Service’ And Position ≠ ‘Manager’ (d) Insert Into Emp Values (‘Stone’, ‘Service’, ‘Clerk’, 13000) Retrieval transaction q: Select Name, Position, Salary From Emp Where Department = ‘Service’ Observations: - Interleaving q with t leads to inconsistent read known as “phantom problem” - Locking existing records cannot prevent this problem ☞ Phantom problem : The query could no longer lock, because tuples have been deleted or are not yet existing but will be inserted in the future Concurrency Control on Relational Databases

1. Predicate-Oriented Concurrency Control Predicate Locking Hyperplane Associate with each operation on table R(A1, ..., An) a set C of conditions that covers a set H(C) of – existing or conceivable – tuples with Each operation locks its H(C) Compatibility Predicate locks on predicates Ct and Ct‘ on behalf of transactions t and t‘ in modes mt and mt‘ are compatible if t = t‘ or both mt and mt‘ are read (shared) mode or H(Ct) ∩ H(Ct‘) = Φ Concurrency Control on Relational Databases

1. Predicate-Oriented Concurrency Control Example 8.2 Testing whether H(Ct) ∩ H(Ct‘) = Φ is NP-complete For preventing the phantom problem it is sufficient that queries lock predicates and insert, update, and delete operations lock individual records, and compatibility is checked by testing that an update-affected record does not satisfy any of the query predicate locks Concurrency Control on Relational Databases

2. Relational Update Transactions Transactions are sequences of insert, delete, or modify operations (in the style of SQL updates) Define notions of serializability along the lines of the classical ones The semantic information available on transaction effects can be exploited to allow more concurrency Definition 8.1 (IDM Transaction): An IDM transaction over a database schema D is a finite sequence of update operations (insertions, deletions, modifications) over D. If is an IDM transaction over a given database, the effect of , , is defined as ☞ Effect : Semantics of the update operations Concurrency Control on Relational Databases

2. Relational Update Transactions Transaction Equivalence Commutativity Rules Two update operations commute if they refer to distinct tuples Definition 8.2 (Transaction Equivalence): Two IDM transactions over the same database schema are equivalent, written , if , i.e., and have the same effect. Concurrency Control on Relational Databases

2. Relational Update Transactions Simplification Rules Simplification rules can be used for transaction optimization. Concurrency Control on Relational Databases

2. Relational Update Transactions Final State Serializability Improve histories by removing redundant updates or simplifying individual transactions. Definition 8.3 (Final State Serializability): A history s for a set of IDM transactions is final state serializable if for some serial history for T. Let FSRIDM denote the class of all final state serializable histories (for ). Concurrency Control on Relational Databases

2. Relational Update Transactions Testing Membership in FSRIDM Thus, “exact“ testing is no easier than for page model transactions when semanti c information is present. Theorem 8.1: The problem of testing whether a given history is in FSRIDM is NP complete. Concurrency Control on Relational Databases

2. Relational Update Transactions Conflict Serializability Definition 8.4 (Conflict Serializability): A history for a set of n transactions is conflict serializable if the equivalence of to a serial history can be proven using the commutativity rules alone. Let CSRIDM denote the class of all conflict serializable histories (for ). Definition 8.5 (Conflict Graph): Let T be a set of IDM transactions and a history for . The conflict graph of s is defined by: is in if for transactions and in , , there is an update in and an update in s.t. And is not equivalent to (i.e., does not hold). Theorem 8.2: Let s be a history for a set T of transactions. Then s is in CSRIDM iff G(s) is acyclic. Concurrency Control on Relational Databases

2. Relational Update Transactions Example 8.6 Consider s = m2(1;2) m1(2;3) m2(3;2) G(s) is cyclic, so s is not in CSRIDM On the other hand, s  m1(2;3) m2(1;2) m2(3;2)  t1 t2 s is in FSRIDM CSRIDM ⊂ FSRIDM t1 t2 m1(2;3) m2(3;2) m2(1;2) m1(2;3) s = m2(1;2) m1(2;3) m2(3;2) = m(1;2) m(3;2) t1 t2 = m1(2;3) m2(1;2) m2(3;2) = m(2;3)m(3;2) m(1;2) = m(3;2) m(1;2) Consequence: CSRIDM is a strict subset of FSRIDM Concurrency Control on Relational Databases

2. Relational Update Transactions Extended Conflict Serializability Conflict serializability : only take local conflicts into account Final state serializability : look at entire context at once Extended conflicts serializability : between single updates u from one transaction and prefixes of other transactions occurring in a given history prior to u Definition 8.6 (Extended Conflict Graph / Serializability): Let be a history for a set of transactions. (1) The extended conflict graph of is defined by: is in if there is an update in s.t. and does not commute with the projection of onto . (2) is extended conflict serializable if is acyclic. Let ECSRIDM denote the class of all extended conflict-serializable histories. Concurrency Control on Relational Databases

2. Relational Update Transactions Example 8.7 t1 t2 m2(1;2) m1(2;3) m1(2;3) m2(3;2) ☞ Example 8.6 s ∈ CSRIDM s ∈ FSRIDM G(s) is cyclic, but s ∈ ECSRIDM Theorem 8.3: CSRIDM ⊂ ECSRIDM ⊂ FSRIDM Concurrency Control on Relational Databases

3. Exploiting Transaction Program Knowledge Transaction Chopping Short transactions need less locks Short transactions cause potentially less lock contention Long transactions can be broken into smaller pieces Assumption: all potentially concurrent app programs are known in advance and their structure and resulting access patterns can be precisely analyzed Definition 8.8 (Transaction Chopping): A chopping of transaction is a decomposition of into pieces s.t. every step of is contained in exactly one piece and the step order is preserved. Definition 8.10 (Correct Chopping): A chopping of is correct if every execution of the transaction pieces is conflict-equivalent to a serial history of under a protocol with • transaction pieces obey the execution precedences of the original programs. • each piece is executed as a unit under a CSR scheduler. Concurrency Control on Relational Databases

3. Exploiting Transaction Program Knowledge Short Transactions Are Good Concurrency Control on Relational Databases

3. Exploiting Transaction Program Knowledge Chopping Graph Definition 8.9 (Chopping Graph): For a chopping of transaction set the chopping graph is an undirected graph s.t. • the nodes of are the transaction pieces • for two pieces , from different transactions contains a edge between and if and contain conflicting operations • for two pieces , from the same transaction contains an edge Theorem 8.5: A chopping is correct if the associated chopping graph does not contain an sc cycle (i.e., a cycle that involves at least one edge and at least one edge. Concurrency Control on Relational Databases

3. Exploiting Transaction Program Knowledge Chopping Graph Concurrency Control on Relational Databases

3. Exploiting Transaction Program Knowledge Applicability of Chopping Directly applicable to straight-line, parameter-less SQL programs with predicate locking. Needs to conservatively derive covering program for parameterized SQL, if-then-else and loops, and needs to be conservative about c edges Concurrency Control on Relational Databases