1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 2: Enforcing Serializable Schedules Professor Chen Li.

Slides:



Advertisements
Similar presentations
1 Concurrency Control III Dead Lock Time Stamp Ordering Validation Scheme.
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 (資料庫系統)
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.
Concurrency II. Shared/Exclusive Locks Problem: while simple locks + 2PL guarantee conflict­serializability, they do not allow two readers of DB element.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
1 Concurrency Control Conflict serializability Two phase locking Optimistic concurrency control Source: slides by Hector Garcia-Molina.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control Professor Elke A. Rundensteiner.
Concurrency Control II
Cs4432concurrency control1 CS4432: Database Systems II Lecture #23 Concurrency Control Professor Elke A. Rundensteiner.
Concurrency Control Enforcing Serializability by Locks
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control: Locking-based Protocols Professor Elke A. Rundensteiner.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 4: More on Locks Professor Chen Li.
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.
CSIS 7102 Spring 2004 Lecture 5 : Non-locking based concurrency control (and some more lock-based ones, too) Dr. King-Ip Lin.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 5: Tree-based Concurrency Control and Validation Currency Control Professor.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 7: View-Serializable Schedules Professor Chen Li.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 6: Cascading Rollbacks, Deadlocks, and Long Transactions Professor Chen Li.
Quick Review of Apr 29 material
Concurrent Transactions Even when there is no “failure,” several transactions can interact to turn a consistent state into an inconsistent state.
ICS 421 Spring 2010 Transactions & Concurrency Control (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa.
Concurrency Control A.Sri Harsha Enforcing Serializability of Locks.
Concurrency Control By Donavon Norwood Ankit Patel Aniket Mulye 1.
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,
Concurrency Control John Ortiz.
CS4432transaction management1 CS4432: Database Systems II Lecture #23 Transaction Management Professor Elke A. Rundensteiner.
18.7 The Tree Protocol Andy Yang. Outline Introduction Motivation Rules for Access to Tree-Structured Data Why the Tree Protocol Works.
Cs4432concurrency control1 CS4432: Database Systems II Concurrency Control.
Chapter 181 Chapter 18: Concurrency Control (Slides by Hector Garcia-Molina,
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control: Locking-based Protocols Professor Elke A. Rundensteiner.
Concurrency control In production environments, it is unlikely that we can limit our system to just one user at a time. – Consequently, it is possible.
1 CS542 Concurrency Control: Theory and Protocol Professor Elke A. Rundensteiner.
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.
Concurrency Control Introduction Lock-Based Protocols
Jinze Liu. Option 1: run system, recording P(S); at end of day, check for P(S) cycles and declare if execution was good.
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Concurrency Control 2004, Spring Pusan National University Ki-Joune Li.
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:
1 Concurrency Control By Ankit Patel. 2 INTRODUCTION Enforcing serializability by locks Locks Locking scheduler Two phase locking Locking systems with.
Transaction Management
Concurrency Control.
Lecture 3 Concurrency control techniques
Concurrency Control.
Multiple Granularity Granularity is the size of data item  allowed to lock. Multiple Granularity is the hierarchically breaking up the database into portions.
Part- A Transaction Management
Enforcing Serializability by Locks
By Donavon Norwood Ankit Patel 112 Aniket Mulye 111
Concurrency Control 11/22/2018.
Distributed Transactions
Locks and Locking Mode ( )
Yan Huang - CSCI5330 Database Implementation – Concurrency Control
Basic Two Phase Locking Protocol
6.830 Lecture 12 Transactions: Isolation
6.830 Lecture 14 Two-phase Locking Recap Optimistic Concurrency Control 10/28/2015.
Chapter 15 : Concurrency Control
ENFORCING SERIALIZABILITY BY LOCKS
Lecture 22: Intro to Transactions & Logging IV
Transaction Management
CPSC-608 Database Systems
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Database Systems (資料庫系統)
Lecture 18: Concurrency Control
Database Systems (資料庫系統)
Presentation transcript:

1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 2: Enforcing Serializable Schedules Professor Chen Li

ICS214BNotes 022 How to enforce serializable schedules? Option 1: run system, recording P(S); at end of day, check for P(S) cycles and declare if execution was good

ICS214BNotes 023 Option 2: prevent P(S) cycles from occurring T 1 T 2 …..T n Scheduler DB How to enforce serializable schedules?

ICS214BNotes 024 A locking protocol Two new actions: lock (exclusive):l i (A) unlock:u i (A) scheduler T 1 T 2 lock table

ICS214BNotes 025 Rule #1: Well-formed transactions T i : … l i (A) … p i (A) … u i (A)... 1) Lock an element before accessing it 2) Unlock the element after accessing it

ICS214BNotes 026 Rule #2 Legal scheduler S = …….. l i (A) ………... u i (A) ……... Once an element A is locked by one transaction Ti, the schedule will not grant any other lock requests on A no l j (A)

ICS214BNotes 027 What schedules are legal? What transactions are well-formed? S1 = l 1 (A)l 1 (B)r 1 (A)w 1 (B)l 2 (B)u 1 (A)u 1 (B) r 2 (B)w 2 (B)u 2 (B)l 3 (B)r 3 (B)u 3 (B) S2 = l 1 (A)r 1 (A)w 1 (B)u 1 (A)u 1 (B) l 2 (B)r 2 (B)w 2 (B)l 3 (B)r 3 (B)u 3 (B) S3 = l 1 (A)r 1 (A)u 1 (A)l 1 (B)w 1 (B)u 1 (B) l 2 (B)r 2 (B)w 2 (B)u 2 (B)l 3 (B)r 3 (B)u 3 (B) Exercise

ICS214BNotes 028 Another problem: schedule F is still allowed, but it’s bad! T1 T l 1 (A);Read(A) A A+100;Write(A);u 1 (A) 125 l 2 (A);Read(A) A Ax2;Write(A);u 2 (A) 250 l 2 (B);Read(B) B Bx2;Write(B);u 2 (B) 50 l 1 (B);Read(B) B B+100;Write(B);u 1 (B) A B

ICS214BNotes 029 Rule #3 Two phase locking (2PL) T i = ……. l i (A) ………... u i (A) ……... A transaction once releases a lock, it cannot request more locks. no unlocks no locks

ICS214BNotes 0210 # locks held by Ti Time Growing Shrinking Phase Phase

ICS214BNotes 0211 Schedule G request delayed

ICS214BNotes 0212 Schedule G request delayed

ICS214BNotes 0213 Schedule G request delayed

ICS214BNotes 0214 Schedule H (T 2 reversed) delayed

ICS214BNotes 0215 Assume deadlocked transactions are rolled back –They have no effect –They do not appear in schedule Solution

ICS214BNotes 0216 Next step: Show that rules #1,2,3  conflict- serializable schedules

ICS214BNotes 0217 New Conflict rules for l i (A), u i (A): Check the semantics of the operations, e.g., –l i (A), u j (A) conflict –l i (A), ri(A) conflict; l i (A), wi(A) conflict –ri(A), ui(A) conflict; wi(A), ui(A) conflict Some actions can never become adjacent after legal swaps –,,... Example: l1(A)r1(A)l1(B)u1(A)l2(A)w2(A)w1(B)u2(A)u1(B)

ICS214BNotes 0218 Theorem Rules #1,2,3  conflict (2PL) serializable schedule To help in proof: Definition Shrink(Ti) = SH(Ti) = first unlock action of Ti

ICS214BNotes 0219 Lemma Ti  Tj in S  SH(Ti) < S SH(Tj) Proof of lemma: Ti  Tj means that S = … p i (A) … q j (A) …; p,q conflict By rules 1,2: ui(A) < S lj(A) S = … p i (A) … u i (A) … l j (A)... q j (A) … By rule 3: SH(Ti) SH(Tj) So, SH(Ti) < S SH(Tj)

ICS214BNotes 0220 Proof: (1) Assume P(S) has cycle T 1  T 2  …. T n  T 1 (2) By lemma: SH(T 1 ) < SH(T 2 ) <... < SH(T 1 ) (3) Impossible, so P(S) acyclic (4)  S is conflict serializable Theorem Rules #1,2,3  conflict (2PL) serializable schedule

ICS214BNotes 0221 Beyond this simple 2PL protocol, it is all a matter of improving performance and allowing more concurrency…. –Shared locks –Multiple granularity –Inserts, deletes, and phantoms –Other types of concurrency control mechanisms

ICS214BNotes 0222 Shared locks S =...l 1 (A) r 1 (A) u 1 (A) … l 2 (A) r 2 (A) u 2 (A) … read only, no conflict Use “shared” lock: S=... ls 1 (A) r 1 (A) ls 2 (A) r 2 (A) …. us 1 (A) us 2 (A)

ICS214BNotes 0223 Lock actions l-t i (A): lock A in t mode (t is S or X) u-t i (A): unlock t mode (t is S or X) “S” = “Shared”, “X” = “Exclusive” Shorthand: u i (A): unlock whatever modes T i has locked A

ICS214BNotes 0224 Rule #1 Well formed transactions T i =... l-S 1 (A) … r 1 (A) … u 1 (A) … T i =... l-X 1 (A) … w 1 (A) … u 1 (A) … Lock an element before accessing it Release the lock afterwards

ICS214BNotes 0225 What about transactions that read and write same object? Option 1: Request exclusive lock T i =...l-X 1 (A) … r 1 (A)... w 1 (A)... u(A) …

ICS214BNotes 0226 Option 2: Upgrade (E.g., need to read, but don’t know if will write…) T i =... l-S 1 (A) … r 1 (A)... l-X 1 (A) …w 1 (A)...u(A)… Think of - Get 2nd lock on A, or - Drop S, get X lock

ICS214BNotes 0227 Rule #2 Legal scheduler S =....l-S i (A) … … u i (A) … l-S j (A) OK, but no l-X j (A) S =... l-X i (A) … … u i (A) … no l-X j (A) no l-S j (A)

ICS214BNotes 0228 A way to summarize Rule #2 Compatibility matrix: “comp” S X S true false Xfalse false

ICS214BNotes 0229 Rule # 3 2PL transactions No change: Locking must precede unlocking, i.e., No action sli(X) or xli(X) can be preceded by ui(X)

ICS214BNotes 0230 Theorem Rules 1,2,3  Conf.serializable for S/X locks schedules