Download presentation
Presentation is loading. Please wait.
Published byAxel Fairburn Modified over 9 years ago
1
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 7: View-Serializable Schedules Professor Chen Li
2
ICS214BNotes 072 View Serializability Conflict equivalentView equivalent Conflict serializableView serializable
3
ICS214BNotes 073 Motivating example Schedule Q T 1 T 2 T 3 Read(A) Write(A)
4
ICS214BNotes 074 Same as Q = r 1 (A) w 2 (A) w 1 (A) w 3 (A) P(Q): T 1 T 2 T 3 Not conflict serializable!
5
ICS214BNotes 075 But now compare Q to Ss, a serial schedule: QT 1 T 2 T 3 Read(A) Write(A) Write(A) Write(A) SsT 1 T 2 T 3 Read(A) Write(A) Write(A) Write(A)
6
ICS214BNotes 076 T 1 reads same thing in Q, Ss T 2, T 3 read same thing (nothing?) After Q or Ss, DB is left in same state So what is wrong with Q?
7
ICS214BNotes 077 Definition Schedules S 1,S 2 are View Equivalent if: (1) If in S 1: w j (A) r i (A) then in S 2: w j (A) r i (A) (2) If in S 1: r i (A) reads initial DB value, then in S 2: r i (A) also reads initial DB value (3) If in S 1: T i does last write on A, then in S 2: T i also does last write on A means “reads value produced”
8
ICS214BNotes 078 Definition Schedule S 1 is View Serializable if it is view equivalent to some serial schedule
9
ICS214BNotes 079 View Conflict Serializable ? View Serializable Conflict Serializable e.g., See Schedule Q Conflict Serializable View Serializable ?
10
ICS214BNotes 0710 Lemma Conflict Serializable View Serializable Proof: Swapping non-conflicting actions does not change what transactions read nor final DB state
11
ICS214BNotes 0711 Diagram All schedules View Serializable Conflict Serializable
12
ICS214BNotes 0712 Note: All view serializable schedules that are not conflict serializable, involve useless write S = W 2 (A) … W 3 (A)….. no reads
13
ICS214BNotes 0713 How do we test for view-serializability? P(S) not good enough… (see schedule Q)
14
ICS214BNotes 0714 One problem: some swaps involving conflicting actions are OK… e.g.: S = ….w 2 (A)……r 1 (A).... w 3 (A)… w 4 (A) this action can move if w4(A) exists
15
ICS214BNotes 0715 Another problem: useless writes S = …..W 2 (A)…….. W 1 (A)….. no A reads
16
ICS214BNotes 0716 To check if S is View Serializable Polygraph: (1) Add final transaction T f that reads all DB (eliminates condition 3 of V-S definition) E.g.: S = …..W 1 (A)…….. W 2 (A)… r f (A) Last A write ? add
17
ICS214BNotes 0717 (2) Add initial transaction T b that writes all DB (eliminates condition 2 of V-S definition) E.g.: S = w b (A)... r 1 (A) … w 2 (A) … add ?
18
ICS214BNotes 0718 (3) Create labeled precedence graph of S: (3a) If w i (A) r j (A) in S, add T i T j 0
19
ICS214BNotes 0719 (3b) For each w i (A) r j (A) do consider each w k (A): [T k T b ] - If T i T b T j T f then insert T k T isome new p T j T k - If T i =T b T j T f then insert T j T k - If T i T b T j =T f then insert T k T i p p 0 0
20
ICS214BNotes 0720 (4) Check if LP(S) is “acyclic” (if so, S is V-S) - For each pair of “p” arcs (p 0), choose one
21
ICS214BNotes 0721 Example: check if Q is V-S: Q = r 1 (A) w 2 (A) w 1 (A) w 3 (A) Q’ = w b (A) r 1 (A) w 2 (A) w 1 (A) w 3 (A) r f (A) T3T3 T2T2 T1T1 TfTf TbTb rule 3(a) 0 0 0 0 rule 3(b) 0 0 LP(S) acyclic!! S is V-S
22
ICS214BNotes 0722 Another example: Z=w b (A) r 1 (A) w 2 (A) r 3 (A) w 1 (A) w 3 (A) r f (A) T3T3 T2T2 T1T1 TfTf TbTb 0 0 0 1 1 0 0 0 0 do not pick this one of “1” pair LP(Z) acyclic, so Z is V-S (equivalent to T b T 1 T 2 T 3 T f ) S s =w b (A)r 1 (A)w 1 (A)w 2 (A)r 3 (A)w 3 (A)r f (A)
23
ICS214BNotes 0723 Checking view serializability is expensive Still, V-S useful in some cases...
24
ICS214BNotes 0724 Example on useless transactions: S = w 1 (A) r 2 (A) w 2 (B) r 1 (B) w 3 (A) w 3 (B) T b w 1 (A) r 2 (A)w 2 (B) r 1 (B) w 3 (A)w 3 (B) T f 0 S’ = T3T3 T2T2 T1T1 TfTf TbTb 0 0
25
ICS214BNotes 0725 If we only care about final state –remove T 1, T 2 –I.e., remove useless transactions If we care what T 1, T 2 read (view equivalence), then do not remove useless transactions
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.