Universität Karlsruhe (TH) © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Chapter 4 Isolation: Correctness in the read/write model.

Slides:



Advertisements
Similar presentations
Universität Karlsruhe (TH) © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 2 Chapter 2 Model for transactions.
Advertisements

Universität Karlsruhe (TH) TAV 10© 2007 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. Böhm Chapter 10 Distributed Transactions: Synchronization.
Database Systems (資料庫系統)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
1 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
Introduction to Database Systems1 Concurrency Control CC.Lecture 1.
1 Integrity Ioan Despi Transactions: transaction concept, transaction state implementation of atomicity and durability concurrent executions serializability,
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.
Transactions (Chapter ). What is it? Transaction - a logical unit of database processing Motivation - want consistent change of state in data Transactions.
1 CS216 Advanced Database Systems Shivnath Babu Notes 11: Concurrency Control.
Concurrent Transactions Even when there is no “failure,” several transactions can interact to turn a consistent state into an inconsistent state.
Wolfgang Miller / / 1 Concurrency Controll Algorithms Concurrency Control Algorithms Chapter 4.
ICS 421 Spring 2010 Transactions & Concurrency Control (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
©Silberschatz, Korth and Sudarshan15.1Database System ConceptsTransactions Transaction Concept Transaction State Implementation of Atomicity and Durability.
CONCURRENCY CONTROL 18.1 Serial and Serializable Schedule By: Nitin Mathur Id: 110 CS: 257.
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.
Transactions or Concurrency Control. Introduction A program which operates on a DB performs 2 kinds of operations: –Access to the Database (Read/Write)
Universität Karlsruhe (TH) © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 2 Chapter 2 Model for transactions.
Transactions. Definitions Transaction (program): A series of Read/Write operations on items in a Database. Example: Transaction 1 Read(C) Read(A) Write(A)
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
Concurrency Control 18.1 – 18.2 Chiu Luk CS257 Database Systems Principles Spring 2009.
Quick Review of Apr 24 material Sorting (Sections 13.4) Sort-merge Algorithm for external sorting Join Operation implementations (sect. 13.5) –Size estimation.
Transaction. A transaction is an event which occurs on the database. Generally a transaction reads a value from the database or writes a value to the.
Academic Year 2014 Spring Academic Year 2014 Spring.
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.
CS411 Database Systems Kazuhiro Minami 14: Concurrency Control.
TRANSACTIONS. Objectives Transaction Concept Transaction State Concurrent Executions Serializability Recoverability Implementation of Isolation Transaction.
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.
Transaction Lectured by, Jesmin Akhter, Assistant professor, IIT, JU.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
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.
Computing & Information Sciences Kansas State University Wednesday, 05 Nov 2008CIS 560: Database System Concepts Lecture 28 of 42 Wednesday, 05 November.
Chapter 14 Transactions Yonsei University 1 st Semester, 2015 Sanghyun Park.
Degrees of Isolation – A Theoretical Formulation Presented by Balaji Sethuraman.
1 Concurrency control lock-base protocols timestamp-based protocols validation-based protocols Ioan Despi.
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.
Group members :- 1.Vipul S. Basapati ( ) 2.Kathan Tripathi ( )
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:
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
Multiversion Concurrency Control
Chapter 14: Transactions
Chap. 3 Concurrency Control (covering 3.8 ~ 3.11)
CS216: Data-Intensive Computing Systems
Schedules and Serializability
Chapter 6: Concurrency Control on Objects: Notions of Correctness
CSIS 7102 Spring 2004 Lecture 2 : Serializability
Transactions.
Transaction Management Overview
CIS 720 Concurrency Control.
Transactional Information Systems:
Lecture 21: Concurrency & Locking
Chapter 15 : Concurrency Control
Transaction management
Chapter 5: Multiversion Concurrency Control
Distributed Database Management Systems
Outline Introduction Background Distributed DBMS Architecture
Presentation transcript:

Universität Karlsruhe (TH) © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Chapter 4 Isolation: Correctness in the read/write model

2 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Agenda Concurrent transactions Histories and schedules Correct histories and schedules

3 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Concurrent transactions

4 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Transaction model revisited (1) Definition 4.1 (Read/Write Model Transaction): A transaction t i is a partial order (op i,< i ), with op i all operations in t i and 1. op i  {r i (x),w i (x) | x is data element }  {a i,c i } (op’ i = op i \ {a i,c i }) 2.  p  op i p = c i  p = a i  (  q  op’ i q < i p) 3. r i (x),w i (x)  op’ i  (r i (x) < i w i (x)  w i (x) < i r i (x)) 4. a i  op i  c i  op i and c i  op i  a i  op i

5 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Transaction model revisited (2) Definition 4.2 Special case: totally ordered transactions. Sequential transaction: (  i,< i ) is total order  Sufficient for the single-processor case. Transaction t i is  aborted, if a i  t i  committed, if c i  t i  completed, if aborted or committed.

6 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Two steps to concurrency Step 1: Find a formalism for describing the interleaved and concurrent execution of a set of transactions.  The formalism should include the formal characteristics of transactions.  In addition it must ensure that operations that are in conflict are executed in sequence. Step 2: Ultimately we wish to know how to arrange the operations that are in conflict such that we obtain a correct ordering of the operations.  What definition of correctness? Histories and schedules Serializability

7 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Histories and schedules

8 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.3 (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. A history for T is a pair h=(op(h),< h ) s.t. (a) op(h)   i=1..n op i (b) for all i, 1  i  n: c i  op(h)  a i  op(h) (c)  i=1..n < i  < h (d) for all i, 1  i  n, and all p  op’ i : p < h c i or p < h a i (e) for all p, q  op(h)\  i=1..n {a i, c i }) s.t. at least one of them is a write and both access the same data item: p < h q or q < h p Histories

9 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.3 (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. A history for T is a pair h=(op(h),< h ) s.t. (a) op(h)   i=1..n op i (b) for all i, 1  i  n: c i  op(h)  a i  op(h) (c)  i=1..n < i  < h (d) for all i, 1  i  n, and all p  op’ i : p < h c i or p < h a i (e) for all p, q  op(h)\  i=1..n {a i, c i }) s.t. at least one of them is a write and both access the same data item: p < h q or q < h p Histories all operations from all transactions are included

10 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.3 (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. A history for T is a pair h=(op(h),< h ) s.t. (a) op(h)   i=1..n op i (b) for all i, 1  i  n: c i  op(h)  a i  op(h) (c)  i=1..n < i  < h (d) for all i, 1  i  n, and all p  op’ i : p < h c i or p < h a i (e) for all p, q  op(h)\  i=1..n {a i, c i }) s.t. at least one of them is a write and both access the same data item: p < h q or q < h p Histories each transaction includes exactly one completion operation

11 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.3 (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. A history for T is a pair h=(op(h),< h ) s.t. (a) op(h)   i=1..n op i (b) for all i, 1  i  n: c i  op(h)  a i  op(h) (c)  i=1..n < i  < h (d) for all i, 1  i  n, and all p  op’ i : p < h c i or p < h a i (e) for all p, q  op(h)\  i=1..n {a i, c i }) s.t. at least one of them is a write and both access the same data item: p < h q or q < h p Histories the ordering within each transaction is preserved

12 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.3 (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. A history for T is a pair h=(op(h),< h ) s.t. (a) op(h)   i=1..n op i (b) for all i, 1  i  n: c i  op(h)  a i  op(h) (c)  i=1..n < i  < h (d) for all i, 1  i  n, and all p  op’ i : p < h c i or p < h a i (e) for all p, q  op(h)\  i=1..n {a i, c i }) s.t. at least one of them is a write and both access the same data item: p < h q or q < h p Histories the completion operation is the final operation in each transaction

13 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.3 (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. A history for T is a pair h=(op(h),< h ) s.t. (a) op(h)   i=1..n op i (b) for all i, 1  i  n: c i  op(h)  a i  op(h) (c)  i=1..n < i  < h (d) for all i, 1  i  n, and all p  op’ i : p < h c i or p < h a i (e) for all p, q  op(h)\  i=1..n {a i, c i }) s.t. at least one of them is a write and both access the same data item: p < h q or q < h p Histories operations in conflict are strictly ordered

14 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.4 (Serial history): A history h is serial if for any two transactions t i and t j in h, where i  j, all operations from t i are ordered in h before all operations from t j or vice versa. Histories Definition 4.5 (Totally ordered history): A history h is totally ordered if in h=(op(h),< h ), < h is a total order, i.e., all operations from op(h) are ordered in sequence.

15 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.3 (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. A history for T is a pair h=(op(h),< h ) s.t. (a) op(h)   i=1..n op i (b) for all i, 1  i  n: c i  op(h)  a i  op(h) (c)  i=1..n < i  < h (d) for all i, 1  i  n, and all p  op’ i : p < h c i or p < h a i (e) for all p, q  op(h)\  i=1..n {a i, c i }) s.t. at least one of them is a write and both access the same data item: p < h q or q < h p Definition 4.6 (Schedules): 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. A schedule for T is a pair s=(op(s),< s ) s.t. (a) op(h)   i=1..n op i (b) for all i, 1  i  n: c i  op(h)  a i  op(h) (c)  i=1..n < i  < h (d) for all i, 1  i  n, and all p  op’ i : p < h c i or p < h a i (e) for all p, q  op(h)\  i=1..n {a i, c i }) s.t. at least one of them is a write and both access the same data item: p < h q or q < h p Schedules c i  op(h)  a i  op(h) 

16 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Schedules and Histories A schedule is a prefix of a history. A history is a projection of a schedule on completed transactions. A committed projection of a schedule is a projection on committed transactions.

17 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 History: example Example 4.7: Suppose T = {t 1, t 3, t 4 } with t 1 = r 1 (x)  w 1 (x) t 3 = r 3 (x)  w 3 (y)  w 3 (x) t 4 = r 4 (y)  w 4 (x)  w 4 (y)  w 4 (z) One history h 1 over T is: r 3 (x)  w 3 (y)  w 3 (x)  c 3   h 1 = r 4 (y)  w 4 (x)  w 4 (y)  w 4 (z)  c 4  r 1 (x)  w 1 (x)  c 1

18 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Schedule: example Schedule over T as a prefix of h 1 : r 3 (x)  w 3 (y)  w 3 (x)  c 3   s 1 = r 4 (y)  w 4 (x)  w 4 (y)  w 4 (z)  c 4  r 1 (x)  w 1 (x)  c 1

19 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Example 4.8: totally ordered history: h1= 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 c 2 a 3 totally ordered schedules (history prefixes): s2 = r 1 (x) r 2 (z) r 3 (x) w 2 (x) w 1 (x) s3 = 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 serial history: h4= r 1 (x) w 1 (x) r 1 (y) w 1 (y) c 1 r 3 (x) r 3 (y) w 3 (z) a 3 r 2 (z) w 2 (x) w 2 (z) c 2 History and schedule: example r 1 (x)w 1 (x) r 1 (y) w 1 (y) r 2 (z)w 2 (x) w 2 (z) r 3 (x)w 3 (z) r 3 (y)

20 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Example 4.8: totally ordered schedule: s5= r 1 (x) w 1 (x) r 1 (y) w 1 (y) c 1 r 3 (x) r 3 (y) w 3 (z) a 3 r 2 (z) w 2 (x) w 2 (z) history as a schedule prefix: h6 = r 1 (x) w 1 (x) r 1 (y) w 1 (y) c 1 r 3 (x) r 3 (y) w 3 (z) a 3 history as a committed projection: h7= r 1 (x) w 1 (x) r 1 (y) w 1 (y) c 1 History and schedule: example r 1 (x)w 1 (x) r 1 (y) w 1 (y) r 2 (z)w 2 (x) w 2 (z) r 3 (x)w 3 (z) r 3 (y)

21 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Transaction sets of a schedule (1) Definition 4. 9 (Transaction sets of a schedule) Transactions occurring partially or completely in s: trans(s) := {t i | s contains operations from t i } Transactions aborted in s: abort(s) := {t i | a i  s} Transactions committed in s: commit(s) := {t i | c i  s} Transactions still active in s: active(s) := trans(s) \ (commit(s)  abort(s)) Transactions completed in s: complete(s) := commit(s)  abort(s) Operations in s: op(s) := {op | op  s}

22 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Transaction sets of a schedule (2) Example 4.10 s1= 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 c 2 a 3 trans(s1) = {t 1, t 2, t 3 } commit(s1) = {t 1, t 2 } abort(s1) ={t 3 } active(s1) = {}

23 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Transaction sets of histories and schedules Remarks 4.11: For each schedule s: commit(s)  abort(s) = commit(s)  active(s) = abort(s)  active(s) =  trans(s) = commit(s)  abort(s)  active(s) For each history h: trans(h) = commit(h)  abort(h) active(h) = 

24 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Correct histories and schedules

25 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Correct schedules (1) Remember: Find a formalism for describing the interleaved and concurrent execution of a set of transactions, Ensure that operations that are in conflict are executed in sequence. However: Given a set of transactions t 1,…,t n, there are many syntactically correct schedules. Which of these guarantee global consistency (semantic correctness)?  What do we mean by global consistency?

26 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 To be useful the criterion should admit a large number of schedules. (This would give us a choice among alternatives, and we could choose one with a high degree of parallelism.) Correct schedules (2) Find: Correctness criterion  : S  {0, 1} for schedules s  S where correct(S) := { s |  (s) = 1}  , correct(S) large s  correct(S) is efficiently decidable. conflict! To be useful the criterion must admit some schedules. Choose the criterion s.t. an algorithm can quickly decide on the correctness of a schedule.

27 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 i.e., are semantically correct Correct schedules (3) correct(S)   : That‘s easy: In serial schedules transactions are isolated.  Serial schedules are correct. However: Serial execution is extremely inefficient.  Find schedules that allow for something better than serial execution, but are in some (which?) sense equivalent to serial schedules. We call such schedules serializable. correct(S) large: Our hope: There are more serializable schedules than just serial schedules. Find a constructive definition of equivalence with a large set of serializable schedules. correct(S) efficiently decidable: The definition should make equivalence efficiently decidable.

28 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Correct schedules (4) Schedules evolve Histories have a known outcome  Define correctness on histories!  Then ensure somehow that schedules result in correct histories!

29 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Final-state equivalence Definition 4.12 Final-state equivalence: Two histories are final-state equivalent if they have the same operations and result in the same final state for any given initial state. Final-state serializability: A history h  H is final-state serializable if there exists a final-state equivalent serial history.  Not very practical: Equivalence considers only the final outcome, not the intermediate states and not whether each individual transaction behaves the same in the two histories.  correct(H) large: Presumably, because of the weak requirement: Much of the past can safely be ignored.  correct(H) efficiently decidable: ?????

30 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Last write in a schedule Definition 4.13 (Last write) Let s be a schedule and x a data element. Last write of x in s is operation w i (x)  s where a i  s  w j (x)  s i  j  w j (x) < s w i (x)  a j  s We write w i (x) = FIN s (x) Example 4.14 s 12 = w 1 (x) w 2 (x) w 2 (y) c 2 w 1 (x) c 1 w 3 (x) w 3 (y) c 3 w 4 (x) a 4 Then w 3 (x) = FIN s 12 (x) w 3 (y) = FIN s 12 (y)

31 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Final-state equivalence Definition 4.15 (final-state equivalence) Let s and s' be schedules. s and s' are final-state equivalent (s  F s')  op(s) = op(s')  x  D FIN s (x) = FIN s' (x) (D database) Two schedules – and by extension, two histories – are final- state equivalent iff both include the same operations and result in the same final state.

32 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Existence of a final-state equivalent serial history implies: Operations in each transaction can commute to a single point in time (equivalence time) without changing FIN. The order of equivalence times determines the serial order.

33 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Take history: r 2 (a) r 1 (f) r 2 (e) w 2 (h) r 1 (h) r 3 (a) r 1 (i) r 1 (d) w 1 (d) w 1 (f) r 1 (b) r 2 (g) w 1 (h) r 2 (d) w 1 (c) w 2 (c) r 1 (e) w 1 (i) c 1 w 3 (h) c 2 c 3. time data elements a b c d e f g h i Write by t2 Write by t3 Read by t2 Read by t3 Legend: Write by t1 Read by t1

34 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Example: time data elements a b c d e f g h i t1t2t3 Write by t2 Write by t3 Read by t2 Read by t3 Legend: Write by t1 Read by t1

35 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 View equivalence Definition 4.16 View equivalence: Two histories are view equivalent if they have the same operations, if each transaction behaves the same in both histories, i.e., its read and write operations have the same effect, and they result in the same final state for any given initial state. View serializability: A history h  H is view serializable if there exists a view equivalent serial history.  correct(H) large: Because of the stronger requirement smaller than for final-state serializability.  correct(H) efficiently decidable: ?????

36 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Definition 4.17 (reads from) Let t i und t j be transactions and s a schedule where t i,t j  s. t j reads x from t i if  x w i (x)< s r j (x) a i ≮ s r j (x)  k  i,j w i (x) < s w k (x) < s r j (x)  a k < s r j (x) A transaction t j reads from t i if there exists a data element x s.t. t j reads x from t i. Notation: t j  s (x) t i and t j  s t i, respectively. Relation (RF: „reads from“) RF(s) := {(t i,x,t j ) | t j  s (x) t i } Read and write in schedules (1)

37 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Example 4.18 Consider s 7 = w 1 (x) w 1 (y) r 2 (u) w 2 (x) r 2 (y) w 2 (y) c 2 w 1 (z) c 1 Then: t 2  s 7 (y) t 1 t 2  s 7 t 1 Read and write in schedules (2)

38 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 View equivalence Definition 4.19 (View equivalence) Two schedules s und s' are view equivalent (s  V s'):  op(s)=op(s') RF(s)=RF(s')  x FIN s (x) = FIN s' (x) Two schedules – and by extension, two histories – are view equivalent iff both include the same operations, read the same states and result in the same final state.

39 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Existence of a view equivalent serial history implies: Operations in each transaction can commute to a single point in time (equivalence time) without changing RF and FIN. The order of equivalence times determines the serial order.

40 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Example: time data elements a b c d e f g h i t1t2t3  Write by t2 Write by t3 Read by t2 Read by t3 Legend: Write by t1 Read by t1

41 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Take history: r 2 (a) r 1 (f) r 2 (e) w 2 (h) r 1 (h) r 3 (a) r 1 (i) r 1 (d) w 1 (d) w 1 (f) r 1 (b) r 2 (g) w 1 (h) r 2 (d) w 1 (c) w 2 (c) r 1 (e) w 1 (i) c 1 w 3 (h) c 2 c 3. time data elements a b c d e f g h i Write by t2 Write by t3 Read by t2 Read by t3 Legend: Write by t1 Read by t1

42 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Example: time data elements a b c d e f g h i t1t2t3 Write by t2 Write by t3 Read by t2 Read by t3 Legend: Write by t1 Read by t1

43 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conflicts (1) Definition 4.20 (in conflict) Two operations p and q in the same or different transactions are in conflict (do not commute) if both access the same data element and at least one of them is a write operation. Remark Notation: p q. in conflict is symmetric.

44 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conflicts (2) w M (R) r S (R) w M (R) w S (R) but r M (R)  r S (R)

45 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conflict equivalence Definition 4.21 Conflict equivalence: Two histories are conflict equivalent if they have the same operations, and operations that are in conflict are ordered the same in both histories. Conflict serializability: A history h  H is conflict serializable if there exists a conflict equivalent serial history h´:  h s serial: h  C h´

46 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conflict relation Definition 4.22 (conflict relation): Let s be a schedule. Then the conflict relation conf(s) is conf(s) = { (p i,q j ) | p i q j, p i < s q j, a i,a j  s } conf describes which operations of the transactions in a schedule are in conflict.

47 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conflict equivalence Definition 4.23 (Conflict equivalence) Two schedules s und s' are conflict equivalent (s  C s')  op(s) = op(s') conf(s) = conf(s') Two schedules – and by extension, two histories – are conflict equivalent iff both include the same operations, and identically order their conflicting operations.

48 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Existence of a conflict equivalent serial history implies: Operations in each transaction can commute to a single point in time (equivalence time) without exchanging operations that are in conflict. The order of equivalence times determines the serial order.

49 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Take history: r 1 (h) r 2 (a) r 1 (f) r 2 (e) w 2 (h) r 3 (a) r 1 (i) r 1 (d) w 1 (d) w 1 (f) r 1 (b) r 2 (g) w 1 (h) r 2 (d) w 1 (c) w 2 (c) r 1 (e) w 1 (i) c 1 w 3 (h) c 2 c 3. time data elements a b c d e f g h i Write by t2 Write by t3 Read by t2 Read by t3 Legend: Write by t1 Read by t1

50 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Conceptual test for serializability Example: time data elements a b c d e f g h i t1t2t3 forbidden  Write by t2 Write by t3 Read by t2 Read by t3 Legend: Write by t1 Read by t1

51 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 Serializability relationships Without proof: correct F (H)  correct V (H)  correct C (H) where  Final-state serializability: F  View serializability: V  Conflict serializability: C

52 © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 4 From histories to schedules Serializability is defined on histories: Only for completed transactions we know their outcome. Moreover, serializability ignores aborted transactions because FIN (and RF, conf) eliminate them from further consideration. Serializability can be extended to schedules if we consider only those transactions that have already committed.  Definition 4.24 (committed projection CP(s) ) Let s be a schedule over T = {t 1,…,t n }. Then CP(s) := s| t i  commit(s) CP(s) is a history.  A schedule s is X-serializable if there exists a serial history h s s.t.  h s serial: CP(s)  X h s