Download presentation
Presentation is loading. Please wait.
1
CONCURRENCY CONTROL 18.1 Serial and Serializable Schedule By: Nitin Mathur Id: 110 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 Disk Buffer INPUT OUTPUT READ & WRITE
4
Transaction Manager Scheduler Buffer Read & Writes Read / Write Requests
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) t := t+100 WRITE (B,t) T2 READ (A,s) s := s*2 WRITE (A,s) READ (B,s) s := s*2 WRITE (B,s) A=B=50 To be consistent the final state should be A=B
7
Serial Schedule T1T2AB50 READ (A,t) t := t+100 WRITE (A,t)150 READ (B,t) t := t+100 WRITE (B,t)150 READ (A,s) s := s*2 WRITE (A,s)300 READ (B,s) s := s*2 WRITE (B,s)300 (T1,T2) A := 2*(A+100)
8
Does the order really matter? T1T2AB50 READ (A,s) s := s*2 WRITE (A,s)100 READ (B,s) s := s*2 WRITE (B,s)100 READ (A,t) t := t+100 WRITE (A,t)200 READ (B,t) t := t+100 WRITE (B,t)200 (T2,T1) The final state of a database is not independent of the order of transaction.
9
Serializable Schedule T1T2AB50 READ (A,t) t := t+100 WRITE (A,t)150 READ (A,s) s := s*2 WRITE (A,s)300 READ (B,t) t := t+100 WRITE (B,t)150 READ (B,s) s := s*2 WRITE (B,s)300 Serializable but not Serial Schedule
10
Non-Serializable Schedule T1T2AB50 READ (A,t) t := t+100 WRITE (A,t)150 READ (A,s) s := s*2 WRITE (A,s)300 READ (B,s) s := s*2 WRITE (B,s)100 READ (B,t) t := t+100 WRITE (B,t)200 A := 2*(A+100) B := 2*B + 100
11
A Serializable Schedule with details T1T2AB50 READ (A,t) t := t+100 WRITE (A,t)150 READ (A,s) s := s*1 WRITE (A,s)150 READ (B,s) s := s*1 WRITE (B,s)50 READ (B,t) t := t+100 WRITE (B,t)150 A := 1*(A+100) B := 1*B + 100
12
Notations for Transaction 1.Action : An expression of the form r i (X) or w i (X) meaning that transaction T i reads or writes, respectively, the database X. 2.Transaction : A transaction T i is a sequence of actions with subscript. 3.Schedule : A schedule S of a transactions T is a sequence of actions, in which for each transaction T i in T, the action of T i appear in the definition of T i itself.
13
Notational Example T1 READ (A,t) t := t+100 WRITE (A,t) READ (B,t) t := t+100 WRITE (B,t) T2 READ (A,s) s := s*2 WRITE (A,s) READ (B,s) s := s*2 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 4 Constructive listening
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.