Download presentation
Presentation is loading. Please wait.
Published byAugust Wiseman Modified over 9 years ago
1
cs4432concurrency control1 CS4432: Database Systems II Lecture #21 Concurrency Control : Theory Professor Elke A. Rundensteiner
2
cs4432concurrency control2 Concepts Transaction: sequence of r i (x), w i (x) actions Conflicting actions: read/write on same resource A: r 1(A) w 2(A) w 1(A) w 2(A) r 1(A) w 2(A) Schedule: represents chronological order in which actions are executed Serial schedule: no interleaving of trans/actions
3
cs4432concurrency control3 Schedule C T1T2 Read(A); A A+100 Write(A); Read(A);A A 2; Write(A); Read(B); B B+100; Write(B); Read(B);B B 2; Write(B); AB25 125 250 125 250250
4
cs4432concurrency control4 Sc’=r 1 (A)w 1 (A) r 1 (B)w 1 (B)r 2 (A)w 2 (A)r 2 (B)w 2 (B) T 1 T 2 Example: Sc=r 1 (A)w 1 (A)r 2 (A)w 2 (A)r 1 (B)w 1 (B)r 2 (B)w 2 (B)
5
cs4432concurrency control5 Returning to Sc Sc=r 1 (A)w 1 (A)r 2 (A)w 2 (A)r 1 (B)w 1 (B)r 2 (B)w 2 (B) T 1 T 2 T 1 T 2 no cycles Sc is “equivalent” to a serial schedule, I.e., in this case (T 1,T 2 ).
6
cs4432concurrency control6 Schedule D T1T2 Read(A); A A+100 Write(A); Read(A);A A 2; Write(A); Read(B);B B 2; Write(B); Read(B); B B+100; Write(B); AB25 125 250 50 150 250150
7
cs4432concurrency control7 Now for Sd: Sd=r 1 (A)w 1 (A)r 2 (A)w 2 (A) r 2 (B)w 2 (B)r 1 (B)w 1 (B) Sd=r 1 (A)w 1 (A) r 1 (B)w 1 (B)r 2 (A)w 2 (A)r 2 (B)w 2 (B) T1 T2
8
cs4432concurrency control8 Or, let’s try for Sd: Sd=r 1 (A)w 1 (A)r 2 (A)w 2 (A) r 2 (B)w 2 (B)r 1 (B)w 1 (B) Sd=r 2 (A)w 2 (A)r 2 (B)w 2 (B) r 1 (A)w 1 (A)r 1 (B)w 1 (B) T1 T2
9
cs4432concurrency control9 In short, Schedule D cannot be “fixed” : Sd=r 1 (A)w 1 (A)r 2 (A)w 2 (A) r 2 (B)w 2 (B)r 1 (B)w 1 (B) as a matter of fact, there seems to be no save way to transform this Sd into an equivalent serial schedule !?
10
cs4432concurrency control10 For Schedule D: Sd=r 1 (A)w 1 (A)r 2 (A)w 2 (A) r 2 (B)w 2 (B)r 1 (B)w 1 (B) T 1 T 2 T 2 T 1 T 1 T 2 Sd cannot be rearranged into serial schedule
11
cs4432concurrency control11 Idea: Swap non-conflicting operation pairs to see if you can go to a serial schedule.
12
cs4432concurrency control12 Definition S 1, S 2 are conflict equivalent schedules if S 1 can be transformed into S 2 by a series of swaps of non-conflicting actions.
13
cs4432concurrency control13 Definition A schedule is conflict serializable if it is conflict equivalent to some serial schedule.
14
cs4432concurrency control14 Answer: A Precedence Graph ! How determine this ?
15
cs4432concurrency control15 Nodes: transactions in S Arcs: Ti Tj whenever - p i (A), q j (A) are actions in S - p i (A) < S q j (A) - at least one of p i, q j is a write Precedence graph P(S) (S is schedule )
16
cs4432concurrency control16 Exercise: What is P(S) for S = w 3 (A) w 2 (C) r 1 (A) w 1 (B) r 1 (C) w 2 (A) r 4 (A) w 4 (D) Is S conflict-serializable?
17
cs4432concurrency control17 Another Exercise: What is P(S) for S = w 1 (A) r 2 (A) r 3 (A) w 4 (A) ? Is S conflict-serializable?
18
cs4432concurrency control18 Lemma S 1, S 2 conflict equivalent P(S 1 )=P(S 2 ) Proof: Assume P(S 1 ) P(S 2 ) T i : T i T j in S 1 and not in S 2 S 1 = …p i (A)... q j (A)… p i, q j S 2 = …q j (A)…p i (A)... conflict S 1, S 2 not conflict equivalent
19
cs4432concurrency control19 Note: P(S 1 )=P(S 2 ) S 1, S 2 conflict equivalent?
20
cs4432concurrency control20 Note: P(S 1 )=P(S 2 ) S 1, S 2 conflict equivalent Counter example: S 1 =w 1 (A) r 2 (A) w 2 (B) r 1 (B) S 2 =r 2 (A) w 1 (A) r 1 (B) w 2 (B)
21
cs4432concurrency control21 Theorem P(S 1 ) acyclic S 1 conflict serializable ( ) Assume S 1 is conflict serializable S s : S s, S 1 conflict equivalent P(S s ) = P(S 1 ) P(S 1 ) acyclic since P(S s ) is acyclic
22
cs4432concurrency control22 ( ) Assume P(S 1 ) is acyclic Transform S 1 as follows: (1) Take T 1 to be transaction with no incident arcs (2) Move all T 1 actions to the front S 1 = ……. q j (A)……. p 1 (A)….. (3) we now have S 1 = (4) repeat above steps to serialize rest! T 1 T 2 T 3 T 4 Theorem P(S 1 ) acyclic S 1 conflict serializable
23
cs4432concurrency control23 Theorem holds: P(S 1 ) acyclic S 1 conflict serializable
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.