Presentation is loading. Please wait.

Presentation is loading. Please wait.

CONCURRENCY CONTROL 18.1 Serial and Serializable Schedule

Similar presentations


Presentation on theme: "CONCURRENCY CONTROL 18.1 Serial and Serializable Schedule"— Presentation transcript:

1 CONCURRENCY CONTROL 18.1 Serial and Serializable Schedule
By: Jiten Oswal Id: 109 CS: 257

2 What Is Concurrency Control & Who controls it?
A process of assuming that the transactions preserve the consistency when executing simultaneously is called Concurrency Control. This consistency is taken care by Scheduler.

3 Flow How Transaction is Executed
INPUT READ & WRITE Disk Buffer OUTPUT

4 Transaction Manager Read / Write Requests Scheduler Read & Writes Buffer

5 Correctness Principle
It’s a principle that states that a transaction starts in a correct database state and ends in a correct database state. Does the system really follow the correctness principal all the time?

6 Basic Example Schedule
T1 READ (A,t) t := t+100 WRITE (A,t) READ (B,t) WRITE (B,t) T2 READ (A,s) s := s*2 WRITE (A,s) READ (B,s) WRITE (B,s) A=B=50 To be consistent the final state should be A=B

7 Serial Schedule (T1,T2) A := 2*(A+100) T1 T2 A B 50 50 READ (A,t)
50 50 READ (A,t) t := t+100 WRITE (A,t) 150 READ (B,t) WRITE (B,t) READ (A,s) s := s*2 WRITE (A,s) 300 READ (B,s) WRITE (B,s) 300 (T1,T2) A := 2*(A+100)

8 Does the order really matter?
T1 T2 A B 50 50 READ (A,s) s := s*2 WRITE (A,s) 100 READ (B,s) WRITE (B,s) 100 READ (A,t) t := t+100 WRITE (A,t) 200 READ (B,t) WRITE (B,t) (T2,T1) The final state of a database is not independent of the order of transaction.

9 Serializable Schedule
T1 T2 A B 50 50 READ (A,t) t := t+100 WRITE (A,t) 150 READ (A,s) s := s*2 WRITE (A,s) 300 READ (B,t) WRITE (B,t) READ (B,s) WRITE (B,s) 300 Serializable but not Serial Schedule

10 Non-Serializable Schedule
T1 T2 A B 50 50 READ (A,t) t := t+100 WRITE (A,t) 150 READ (A,s) s := s*2 WRITE (A,s) 300 READ (B,s) WRITE (B,s) 100 READ (B,t) WRITE (B,t) A := 2*(A+100) B := 2*B + 100

11 A Serializable Schedule with details
T1 T2 A B 50 50 READ (A,t) t := t+100 WRITE (A,t) 150 READ (A,s) s := s*1 WRITE (A,s) 150 READ (B,s) WRITE (B,s) 50 READ (B,t) WRITE (B,t) A := 1*(A+100) B := 1*B + 100

12 Notations for Transaction
Action : An expression of the form ri(X) or wi(X) meaning that transaction Ti reads or writes, respectively, the database X. Transaction : A transaction Ti is a sequence of actions with subscript. Schedule : A schedule S of a transactions T is a sequence of actions, in which for each transaction Ti in T, the action of Ti appear in the definition of Ti itself.

13 Notational Example T1 T2 READ (A,t) t := t+100 WRITE (A,t) READ (B,t)
WRITE (B,t) T2 READ (A,s) s := s*2 WRITE (A,s) READ (B,s) WRITE (B,s) Notation: T1 : r1(A); w1(A); r1(B); w1(B) T2 : r2(A); w2(A); r2(B); w2(B)

14 Thank you


Download ppt "CONCURRENCY CONTROL 18.1 Serial and Serializable Schedule"

Similar presentations


Ads by Google