6/18/2016Transactional Information Systems3-1 Part II: Concurrency Control 3 Concurrency Control: Notions of Correctness for the Page Model 4 Concurrency.

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 (資料庫系統)
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.
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
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
Transactions (Chapter ). What is it? Transaction - a logical unit of database processing Motivation - want consistent change of state in data Transactions.
Kyoung-Hwan Yun (#110). Conflicts Precedence Graphs and a Test for Conflict- Serializability.
1 CS216 Advanced Database Systems Shivnath Babu Notes 11: Concurrency Control.
Universität Karlsruhe (TH) © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Chapter 4 Isolation: Correctness in the read/write model.
CS4432: Database Systems II Lecture #26 Concurrency Control and Recovery Professor Elke A. Rundensteiner.
Tree Locking Protocol Silberchatz and Kedem, JACM, January1980.
ICS 421 Spring 2010 Transactions & Concurrency Control (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa.
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
Concurrency control using transactions 1Transactions.
Chapter 7 Transactions 7.1 Transaction Concept 7.2 Transaction State 7.3 Implementation of Atomicity and Durability 7.4 Concurrent Executions 7.5 Serializability.
©Silberschatz, Korth and Sudarshan15.1Database System ConceptsTransactions Transaction Concept Transaction State Implementation of Atomicity and Durability.
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,
Database Management Systems I Alex Coman, Winter 2006
6/27/2015Transactional Information Systems8-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
1 Introduction to Transaction Processing (1)
Transactions Sylvia Huang CS 157B. Transaction A transaction is a unit of program execution that accesses and possibly updates various data items. A transaction.
TRANSACTIONS. Objectives Transaction Concept Transaction State Concurrent Executions Serializability Recoverability Implementation of Isolation Transaction.
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
Transactions. What is it? Transaction - a logical unit of database processing Motivation - want consistent change of state in data Transactions developed.
Chapter 14 Transactions Yonsei University 1 st Semester, 2015 Sanghyun Park.
Degrees of Isolation – A Theoretical Formulation Presented by Balaji Sethuraman.
1 CSE 480: Database Systems Lecture 24: Concurrency Control.
Concurrency (cont.) Schedule. In multiprogramming environment, Several transaction run concurrently Database consistency can be destroy Schedules to ensure.
CMPSC 274: Transaction Processing Lecture #2: Correctness Divy Agrawal Department of Computer Science UC Santa Barbara.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
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.
1 Transaction Processing Case Study. 2 Interaksi Proses There is table Sells(shop,beverage,price), and suppose that Joe’s Shop sells only Juice for $2.50.
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:
Chapter 8: Concurrency Control on Relational Databases
Transaction Management
Multiversion Concurrency Control
6. Concurrency Control on Objects : Notions of Correctness.
Transactions and Concurrency Control
Chapter 14: Transactions
Transactional Information Systems:
Chap. 3 Concurrency Control (covering 3.8 ~ 3.11)
CS216: Data-Intensive Computing Systems
Database Management System
Chapter 6: Concurrency Control on Objects: Notions of Correctness
CSIS 7102 Spring 2004 Lecture 2 : Serializability
Transactions.
Temple University – CIS Dept. CIS661 – Principles of Data Management
Transactional Information Systems:
Transactions Sylvia Huang CS 157B.
Chapter 10 Transaction Management and Concurrency Control
Lecture 21: Concurrency & Locking
Transactional Information Systems:
Transaction management
Chapter 5: Multiversion Concurrency Control
Chapter 2: Computational Models
Transactional Information Systems
CPSC-608 Database Systems
C. Faloutsos Transactions
Temple University – CIS Dept. CIS616– Principles of Data Management
UNIT -IV Transaction.
Outline Introduction Background Distributed DBMS Architecture
Presentation transcript:

6/18/2016Transactional Information Systems3-1 Part II: Concurrency Control 3 Concurrency Control: Notions of Correctness for the Page Model 4 Concurrency Control Algorithms 5 Multiversion Concurrency Control 6 Concurrency Control on Objects: Notions of Correctness 7 Concurrency Control Algorithms on Objects 8 Concurrency Control on Relational Databases 9 Concurrency Control on Search Structures 10 Implementation and Pragmatic Issues

6/18/2016Transactional Information Systems3-2 Chapter 3: Concurrency Control – Notions of Correctness for the Page Model 3.2 Canonical Synchronization Problems 3.3 Syntax of Histories and Schedules 3.4 Correctness of Histories and Schedules 3.5 Herbrand Semantics of Schedules 3.6 Final-State Serializability 3.7 View Serializability 3.8 Conflict Serializability 3.9 Commit Serializability 3.10 An Alternative Criterion: Interleaving Specifications 3.11 Lessons Learned “Nothing is as practical as a good theory.” (Albert Einstein)

6/18/2016Transactional Information Systems3-3 Lost Update Problem P1TimeP2 /* x = 100 */ r (x) 1 2r (x) x := x+100 4x := x+200 w (x) 5 /* x = 200 */ 6w (x) /* x = 300 */ update “lost” Observation: problem is the interleaving r 1 (x) r 2 (x) w 1 (x) w 2 (x) Example 3.1

6/18/2016Transactional Information Systems3-4 Inconsistent Read Problem P1TimeP2 1r (x) 2x := x – 10 3w (x) sum := 0 4 r (x) 5 r (y) 6 sum := sum +x 7 sum := sum + y 8 9r (y) 10y := y w (y) “sees” wrong sum Observations: problem is the interleaving r 2 (x) w 2 (x) r 1 (x) r 1 (y) r 2 (y) w 2 (y) no problem with sequential execution Example 3.2

6/18/2016Transactional Information Systems3-5 Dirty Read Problem P1TimeP2 r (x) 1 x := x w (x) 3 4r (x) 5x := x failure & rollback 6 7w (x) cannot rely on validity of previously read data Observation: transaction rollbacks could affect concurrent transactions Example 3.3

6/18/2016Transactional Information Systems3-6 Chapter 3: Concurrency Control – Notions of Correctness for the Page Model 3.2 Canonical Synchronization Problems 3.3 Syntax of Histories and Schedules 3.4 Correctness of Histories and Schedules 3.5 Herbrand Semantics of Schedules 3.6 Final-State Serializability 3.7 View Serializability 3.8 Conflict Serializability 3.9 Commit Serializability 3.10 An Alternative Criterion: Interleaving Specifications 3.11 Lessons Learned

6/18/2016Transactional Information Systems3-7 Schedules and Histories Definition 3.1 (Schedules and histories): Let T={t 1,..., t n } be a set of transactions, where each t i  T has the form t i =(op i, < i ) with op i denoting the operations of t i and < i their ordering. (i)A history for T is a pair s=(op(s),< s ) s.t. (a) op(s)   i=1..n op i   i=1..n {a i, c i } (b) for all i, 1  i  n: c i  op(s)  a i  op(s) (c)  i=1..n < i  < s (d) for all i, 1  i  n, and all p  op i : p < s c i or p < s a i (e) for all p, q  op(s) s.t. at least one of them is a write and both access the same data item: p < s q or q < s p (ii) A schedule is a prefix of a history. Definition 3.2 (Serial history): A history s is serial if for any two transactions t i and t j in s, where i  j, all operations from t i are ordered in s before all operations from t j or vice versa.

6/18/2016Transactional Information Systems3-8 Example Schedules and Notation r 1 (x)w 1 (x)c1c1 r 1 (z) r 2 (x)w 2 (y)c2c2 r 3 (z)w 3 (y)c3c3 w 3 (z) Example 3.4: Example 3.6: r 1 (x) r 2 (z) r 3 (x) w 2 (x) w 1 (x) r 3 (y) r 1 (y) w 1 (y) w 2 (z) w 3 (z) c 1 a 3 trans(s):= {t i | s contains step of t i } commit(s):= {t i  trans(s) | c i  s} abort(s):= {t i  trans(s) | a i  s} active(s):= trans(s) – (commit(s)  abort(s))

6/18/2016Transactional Information Systems3-9 Chapter 3: Concurrency Control – Notions of Correctness for the Page Model 3.2 Canonical Synchronization Problems 3.3 Syntax of Histories and Schedules 3.4 Correctness of Histories and Schedules 3.5 Herbrand Semantics of Schedules 3.6 Final-State Serializability 3.7 View Serializability 3.8 Conflict Serializability 3.9 Commit Serializability 3.10 An Alternative Criterion: Interleaving Specifications 3.11 Lessons Learned

6/18/2016Transactional Information Systems3-10 Correctness of Schedules 1.Define equivalence relation  on set S of all schedules. 2.“Good” schedules are those in the equivalence classes of serial schedules. Equivalence must be efficiently decidable. “Good” equivalence classes should be “sufficiently large”. Disregard aborts: assume that all transactions are committed.

6/18/2016Transactional Information Systems3-11 Chapter 3: Concurrency Control – Notions of Correctness for the Page Model 3.2 Canonical Synchronization Problems 3.3 Syntax of Histories and Schedules 3.4 Correctness of Histories and Schedules 3.5 Herbrand Semantics of Schedules 3.6 Final-State Serializability 3.7 View Serializability 3.8 Conflict Serializability 3.9 Commit Serializability 3.10 An Alternative Criterion: Interleaving Specifications 3.11 Lessons Learned

6/18/2016Transactional Information Systems3-12 Chapter 3: Concurrency Control – Notions of Correctness for the Page Model 3.2 Canonical Synchronization Problems 3.3 Syntax of Histories and Schedules 3.4 Correctness of Histories and Schedules 3.5 Herbrand Semantics of Schedules 3.6 Final-State Serializability 3.7 View Serializability 3.8 Conflict Serializability 3.9 Commit Serializability 3.10 An Alternative Criterion: Interleaving Specifications 3.11 Lessons Learned

6/18/2016Transactional Information Systems3-13 Conflict Serializability Definition 3.12 (Conflicts and Conflict Relations): Let s be a schedule, t, t‘  trans(s), t  t‘. (i)Two data operations p  t and q  t‘ are in conflict in s if they access the same data item and at least one of them is a write. (ii){(p, q)} | p, q are in conflict and p < s q} is the conflict relation of s. Definition 3.13 (Conflict Equivalence): Schedules s and s‘ are conflict equivalent, denoted s  c s‘, if op(s) = op(s‘) and conf(s) = conf(s‘). Definition 3.14 (Conflict Serializability): Schedule s is conflict serializable if there is a serial schedule s‘ s.t. s  c s‘. CSR denotes the class of all conflict serializable schedules. Example a: r 1 (x) r 2 (x) r 1 (z) w 1 (x) w 2 (y) r 3 (z) w 3 (y) c 1 c 2 w 3 (z) c 3 Example b: r 2 (x) w 2 (x) r 1 (x) r 1 (y) r 2 (y) w 2 (y) c 1 c 2   CSR   CSR

6/18/2016Transactional Information Systems3-14 Properties of CSR Theorem 3.8: CSR  VSR Example: s = w 1 (x) w 2 (x) w 2 (y) c 2 w 1 (y) c 1 w 3 (x) w 3 (y) c 3 s  VSR, but s  CSR. Theorem 3.9: (i)CSR is monotone. (ii)s  CSR   T (s)  VSR for all T  trans(s) (i.e., CSR is the largest monotone subset of VSR).

6/18/2016Transactional Information Systems3-15 Conflict Graph Definition 3.15 (Conflict Graph): Let s be a schedule. The conflict graph G(s) = (V, E) is a directed graph with vertices V := commit(s) and edges E := {(t, t‘) | t  t‘ and there are steps p  t, q  t‘ with (p, q)  conf(s)}. Theorem 3.10: Let s be a schedule. Then s  CSR iff G(s) is acyclic. Corollary 3.4: Testing if a schedule is in CSR can be done in time polynomial to the schedule‘s number of transactions. Example 3.12: s = r 1 (y) r 3 (w) r 2 (y) w 1 (y) w 1 (x) w 2 (x) w 2 (z) w 3 (x) c 1 c 3 c 2 G(s): t1 t2 t3

6/18/2016Transactional Information Systems3-16 Proof of the Conflict-Graph Theorem Proof of Theorem 3.10: (i) Let s be a schedule in CSR. So there is a serial schedule s‘ with conf(s) = conf(s‘). Now assume that G(s) has a cycle t 1  t 2 ...  t k  t 1. This implies that there are pairs (p 1, q 2 ), (p 2, q 3 ),..., (p k, q 1 ) with p i  t i, q i  t i, p i < s q (i+1), and p i in conflict with q (i+1). Because s‘  c s, it also implies that p i < s‘ q (i+1). Because s‘ is serial, we obtain t i < s‘ t (i+1) for i=1,..., k-1, and t k < s‘ t 1. By transitivity we infer t 1 < s‘ t 2 and t 2 < s‘ t 1, which is impossible. This contradiction shows that the initial assumption is wrong. So G(s) is acyclic. (ii)Let G(s) be acyclic. So it must have at least one source node. The following topological sort produces a total order < of transactions: a) start with a source node (i.e., a node without incoming edges), b) remove this node and all its outgoing edges, c) iterate a) and b) until all nodes have been added to the sorted list. The total transaction ordering order < preserves the edges in G(s); therefore it yields a serial schedule s‘ for which s‘  c s.

6/18/2016Transactional Information Systems3-17 Commutativity and Ordering Rules Commutativity rules: C1: r i (x) r j (y) ~ r j (y) r i (x) if i  j C2: r i (x) w j (y) ~ w j (y) r i (x) if i  j and x  y C3: w i (x) w j (y) ~ w j (y) w i (x) if i  j and x  y Ordering rule: C4: o i (x), p j (y) unordered ~> o i (x) p j (y) if x  y or both o and p are reads Example for transformations of schedules: s = w 1 (x) r 2 (x) w 1 (y) w 1 (z) r 3 (z) w 2 (y) w 3 (y) w 3 (z) ~>[C2] w 1 (x) w 1 (y) r 2 (x) w 1 (z) w 2 (y) r 3 (z) w 3 (y) w 3 (z) ~>[C2] w 1 (x) w 1 (y) w 1 (z) r 2 (x) w 2 (y) r 3 (z) w 3 (y) w 3 (z) = t 1 t 2 t 3

6/18/2016Transactional Information Systems3-18 Commutativity-based Reducibility Definition 3.16 (Commutativity Based Equivalence): Schedules s and s‘ s.t. op(s)=op(s‘) are commutativity based equivalent, denoted s ~* s‘, if s can be transformed into s‘ by applying rules C1, C2, C3, C4 finitely many times. Theorem 3.11: Let s and s‘ be schedules s.t. op(s)=op(s‘). Then s  c s‘ iff s ~* s‘. Definition 3.17 (Commutativity Based Reducibility): Schedule s is commutativity-based reducible if there is a serial schedule s‘ s.t. s ~* s‘. Corollary 3.5: Schedule s is commutativity-based reducible iff s  CSR.

6/18/2016Transactional Information Systems3-19 Order Preserving Conflict Serializability Definition 3.18 (Order Preservation): Schedule s is order preserving conflict serializable if it is conflict equivalent to a serial schedule s‘ and for all t, t‘  trans(s): if t completely precedes t‘ in s, then the same holds in s‘. OCSR denotes the class of all schedules with this property. Theorem 3.12: OCSR  CSR. Example 3.13: s = w 1 (x) r 2 (x) c 2 w 3 (y) c 3 w 1 (y) c 1   CSR   OCSR

6/18/2016Transactional Information Systems3-20 Commit-order Preserving Conflict Serializability Definition 3.19 (Commit Order Preservation): Schedule s is commit order preserving conflict serializable if for all t i, t j  trans(s): if there are p  t i, q  t j with (p,q)  conf(s) then c i < s c j. COCSR denotes the class of all schedules with this property. Theorem 3.13: COCSR  CSR. Example: s = w 3 (y) c 3 w 1 (x) r 2 (x) c 2 w 1 (y) c 1   OCSR   COCSR Theorem 3.15: COCSR  OCSR. Theorem 3.14: Schedule s is in COCSR iff there is a serial schedule s‘ s.t. s  c s‘ and for all t i, t j  trans(s): t i < s‘ t j  c i < s c j.

6/18/2016Transactional Information Systems3-21 Chapter 3: Concurrency Control – Notions of Correctness for the Page Model 3.2 Canonical Synchronization Problems 3.3 Syntax of Histories and Schedules 3.4 Correctness of Histories and Schedules 3.5 Herbrand Semantics of Schedules 3.6 Final-State Serializability 3.7 View Serializability 3.8 Conflict Serializability 3.9 Commit Serializability 3.10 An Alternative Criterion: Interleaving Specifications 3.11 Lessons Learned

6/18/2016Transactional Information Systems3-22 Commit Serializability Definition 3.20 (Closure Properties of Schedule Classes): Let E be a class of schedules. For schedule s let CP(s) denote the projection  commit(s) (s). E is prefix-closed if the following holds: s  E  p  E for each prefix of s. E is commit-closed if the following holds: s  E  CP(s)  E. Theorem 3.16: CSR is prefix-commit-closed, i.e., prefix-closed and commit-closed. Definition 3.21 (Commit Serializability): Schedule s is commit-  -serializable if CP(p) is  -serializable for each prefix p of s, where  can be FSR, VSR, or CSR. The resulting classes of commit-  -serializable schedules are denoted CMFSR, CMVSR, and CMCSR. Theorem 3.17: (i)CMFSR, CMVSR, CMCSR are prefix-commit-closed. (ii)CMCSR  CMVSR  CMFSR

6/18/2016Transactional Information Systems3-23 Chapter 3: Concurrency Control – Notions of Correctness for the Page Model 3.2 Canonical Synchronization Problems 3.3 Syntax of Histories and Schedules 3.4 Correctness of Histories and Schedules 3.5 Herbrand Semantics of Schedules 3.6 Final-State Serializability 3.7 View Serializability 3.8 Conflict Serializability 3.9 Commit Serializability 3.10 An Alternative Criterion: Interleaving Specifications 3.11 Lessons Learned

6/18/2016Transactional Information Systems3-24 Lessons Learned Equivalence to serial history is a natural correctness criterion CSR, albeit less general than VSR, is most appropriate for complexity reasons its monotonicity property its generalizability to semantically rich operations OCSR and COCSR have additional beneficial properties