CS 277: Database System Implementation Notes 11: View Serializability

Slides:



Advertisements
Similar presentations
CM20145 Transactions & Serializability
Advertisements

1 Shivnath Babu Concurrency Control (II) CS216: Data-Intensive Computing Systems.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #21 Concurrency Control : Theory Professor Elke A. Rundensteiner.
Database Systems (資料庫系統)
More About Transaction Management Chapter 10. Contents Transactions that Read Uncommitted Data View Serializability Resolving Deadlocks Distributed Databases.
Conflict Serializability Example Murat Kantarcioglu.
1 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
Introduction to Database Systems1 Concurrency Control CC.Lecture 1.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Database System Principles 18.7 Tree Locking Protocol CS257 Section 1 Spring 2012 Dhruv Jalota ID: 115.
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.
Concurrency Control II
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 2: Enforcing Serializable Schedules Professor Chen Li.
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.
1 CS216 Advanced Database Systems Shivnath Babu Notes 12: Concurrency Control (II)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
Lecture 12 Transactions: Isolation. Transactions What’s hard? – ACID – Concurrency control – Recovery.
Kyoung-Hwan Yun (#110). Conflicts Precedence Graphs and a Test for Conflict- Serializability.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 7: View-Serializable Schedules Professor Chen Li.
1 CS216 Advanced Database Systems Shivnath Babu Notes 11: Concurrency Control.
Prob.1 CSE 255 Query Optimization Problem  CustomerName (  BranchName=‘Storrs’^ Balance > 1000 ( Branch x Account x Depositor))  Consider the Three.
CS4432: Database Systems II Lecture #26 Concurrency Control and Recovery Professor Elke A. Rundensteiner.
Sekolah Tinggi Ilmu Statistik (STIS) 1 Dr. Said Mirza Pahlevi, M.Eng.
Conflict-Serializability Bharath Kumar Manur Venkataramana Class ID No:- 110.
Concurrent Transactions Even when there is no “failure,” several transactions can interact to turn a consistent state into an inconsistent state.
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.
Conflict-Serializability (section 18.2 of Concurrency Control) - Amith KC Student ID –
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)
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,
Concurrency Control 18.1 – 18.2 Chiu Luk CS257 Database Systems Principles Spring 2009.
CS4432transaction management1 CS4432: Database Systems II Lecture #23 Transaction Management Professor Elke A. Rundensteiner.
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.
Cs4432concurrency control1 CS4432: Database Systems II Concurrency Control.
Copyright © 2004 Pearson Education, Inc.. Chapter 17 Introduction to Transaction Processing Concepts and Theory.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control: Locking-based Protocols Professor Elke A. Rundensteiner.
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.
1 Concurrency Control II: Locking and Isolation Levels.
©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.
Chapter 14 Transactions Yonsei University 1 st Semester, 2015 Sanghyun Park.
1 CS542 Concurrency Control: Theory and Protocol Professor Elke A. Rundensteiner.
Concurrency (cont.) Schedule. In multiprogramming environment, Several transaction run concurrently Database consistency can be destroy Schedules to ensure.
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.
Concurrency Control.
CS216: Data-Intensive Computing Systems
Enforcing Serializability by Locks
Transactions.
March 21st – Transactions
Temple University – CIS Dept. CIS661 – Principles of Data Management
Algorithm 2 Algorithm 2 Problem
Distributed Transactions
Transactions Sylvia Huang CS 157B.
Conflict-Serializability (section 18.2 of Concurrency Control)
6.830 Lecture 12 Transactions: Isolation
Conflicts.
Lecture 22: Intro to Transactions & Logging IV
Additional Example 2: Graphing Ordered Pairs Graph and label each point on a coordinate grid. A. L (3, 5) Start at (0, 0)
Transaction management
CONCURRENCY CONTROL 18.1 Serial and Serializable Schedule
C. Faloutsos Transactions
Temple University – CIS Dept. CIS616– Principles of Data Management
Transaction Serializability
Presentation transcript:

CS 277: Database System Implementation Notes 11: View Serializability Arthur Keller CS 277 – Spring 2002 Notes 11

View Serializability Conflict equivalent View equivalent Conflict serializable View serializable CS 277 – Spring 2002 Notes 11

Motivating example Schedule Q T1 T2 T3 Read(A) Write(A) CS 277 – Spring 2002 Notes 11

 Not conflict serializable! Same as Q = r1(A) w2(A) w1(A) w3(A) P(Q): T1 T2 T3  Not conflict serializable! CS 277 – Spring 2002 Notes 11

But now compare Q to Ss, a serial schedule: Q T1 T2 T3 Read(A) Write(A) Write(A) Write(A) Ss T1 T2 T3 Write(A) Write(A) CS 277 – Spring 2002 Notes 11

T1 reads same thing in Q, Ss T2, T3 read samething (nothing?) After Q or Ss, DB is left in same state  So what is wrong with Q? CS 277 – Spring 2002 Notes 11

Definition Schedules S1,S2 are View Equivalent if: (1) If in S1: wj(A)  ri(A) then in S2: wj(A)  ri(A) (2) If in S1: ri(A) reads initial DB value, then in S2: ri(A) also reads initial DB value (3) If in S1: Ti does last write on A, then in S2: Ti also does last write on A  means “reads value produced” CS 277 – Spring 2002 Notes 11

Definition Schedule S1 is View Serializable if it is view equivalent to some serial schedule CS 277 – Spring 2002 Notes 11

Serializable Serializable ? View Conflict Serializable Serializable ? View Serializable  Conflict Serializable e.g., See Schedule Q Conflict Serializable  View Serializable ? CS 277 – Spring 2002 Notes 11

Lemma Conflict Serializable  View Serializable Proof: Swapping non-conflicting actions does not change what transactions read nor final DB state CS 277 – Spring 2002 Notes 11

Venn Diagram All schedules View Serializable Conflict Serializable CS 277 – Spring 2002 Notes 11

Note: All view serializable schedules that are not conflict serializable, involve useless write S = W2(A) … W3(A)….. no reads CS 277 – Spring 2002 Notes 11

How do we test for view-serializability?  P(S) not good enough… (see schedule Q) CS 277 – Spring 2002 Notes 11

One problem: some swaps involving conflicting actions are OK… e.g.: S = ….w2(A)……r1(A).... w3(A)… w4(A) this action can move if this write exists CS 277 – Spring 2002 Notes 11

Another problem: useless writes S = …..W2(A)…….. W1(A)….. no A reads CS 277 – Spring 2002 Notes 11

To check if S is View Serializable (1) Add final transaction Tf that reads all DB (eliminates condition 3 of V-S definition) E.g.: S = …..W1(A)…….. W2(A)… rf(A) Last A write ? add CS 277 – Spring 2002 Notes 11

E.g.: S = wb(A) ... r1(A) … w2(A) … (2) Add initial transaction Tb that writes all DB (eliminates condition 2 of V-S definition) E.g.: S = wb(A) ... r1(A) … w2(A) … ? add CS 277 – Spring 2002 Notes 11

(3) Create labeled precedence graph of S: (3a) If wi(A)  rj(A) in S, add Ti  Tj CS 277 – Spring 2002 Notes 11

(3b) For each wi(A)  rj(A) do consider each wk(A): [Tk Tb] - If Ti Tb  Tj Tf then insert Tk  Ti some new p Tj  Tk - If Ti =Tb  Tj Tf then insert - If Ti Tb  Tj =Tf then insert Tk  Ti p p CS 277 – Spring 2002 Notes 11

(4) Check if LP(S) is “acyclic” (if so, S is V-S) - For each pair of “p” arcs (p  0), choose one CS 277 – Spring 2002 Notes 11

Example: check if Q is V-S: Q = r1(A) w2(A) w1(A) w3(A) Q’ = wb(A) r1(A) w2(A) w1(A) w3(A) rf(A) rule 3(b)  rule 3(a) rule 3(b) T1 Tb T2 Tf LP(S) acyclic!! S is V-S T3 CS 277 – Spring 2002 Notes 11

Z=wb(A) r1(A) w2(A) r3(A) w1(A) w3(A) rf(A) Another example: Z=wb(A) r1(A) w2(A) r3(A) w1(A) w3(A) rf(A) 1  T1 Tb T2 Tf do not pick this one of “1” pair LP(Z) acyclic, so Z is V-S (equivalent to Tb T1 T2 T3 Tf) T3 CS 277 – Spring 2002 Notes 11

Ss=wb(A)r1(A)w1(A)w2(A)r3(A)w3(A)rf(A) T1 T2 T3 Z + Ss indeed do same thing CS 277 – Spring 2002 Notes 11

Checking view serializability is expensive Still, V-S useful in some cases... CS 277 – Spring 2002 Notes 11

Example on useless transactions: S = w1(A) r2(A) w2(B) r1(B) w3(A) w3(B) CS 277 – Spring 2002 Notes 11

Tb w1(A)r2(A)w2(B)r1(B) w3(A)w3(B) Tf S’ = Tb w1(A)r2(A)w2(B)r1(B) w3(A)w3(B) Tf T1 Tb T3 Tf T2 CS 277 – Spring 2002 Notes 11

If we only care about final state  remove T1, T2; i. e If we only care about final state  remove T1, T2; i.e., remove useless transactions If we care what T1, T2 read (view equivalence), then do not remove useless transactions CS 277 – Spring 2002 Notes 11

If all transactions read what they write, (I. e. , Tj= If all transactions read what they write, (I.e., Tj=... Rj(A) … Wj (A)…) then view serializability = conf. serializability [Another way of saying: blind writes appear in any view-serializable schedule that is not conflict serializable] CS 277 – Spring 2002 Notes 11

Proof(. ): say S1 is view-ser. and no blind writes Proof(?): say S1 is view-ser. and no blind writes. S1 V-equiv to Ss, serial schedule. (1) Goal: Show that T1  T2 in P(S1)  T1 <ssT2 (2) Assume T1  T2 if S1 = …w1(A) … r2(A)… (direct read) clearly T1 <ssT2 if S1 = …w1(A)… r3(A) w3(A) ... r2(A)… also T1 <ssT2 if S1 =...r1(A) r3(A) … w1(A) … w3(A) … r2(A) not possible: T1,T3 not serializable Other cases similar... CS 277 – Spring 2002 Notes 11

Implications: If no blind writes, view-ser  conf-ser P(S) acyclic  all transactions read the same as in a serial schedule CS 277 – Spring 2002 Notes 11