Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 277 – Spring 2002Notes 111 CS 277: Database System Implementation Notes 11: View Serializability Arthur Keller.

Similar presentations


Presentation on theme: "CS 277 – Spring 2002Notes 111 CS 277: Database System Implementation Notes 11: View Serializability Arthur Keller."— Presentation transcript:

1 CS 277 – Spring 2002Notes 111 CS 277: Database System Implementation Notes 11: View Serializability Arthur Keller

2 CS 277 – Spring 2002Notes 112 View Serializability Conflict equivalentView equivalent Conflict serializableView serializable

3 CS 277 – Spring 2002Notes 113 Motivating example Schedule Q T 1 T 2 T 3 Read(A) Write(A)

4 CS 277 – Spring 2002Notes 114 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 CS 277 – Spring 2002Notes 115 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 CS 277 – Spring 2002Notes 116 T 1 reads same thing in Q, Ss T 2, T 3 read samething (nothing?) After Q or Ss, DB is left in same state  So what is wrong with Q?

7 CS 277 – Spring 2002Notes 117 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 CS 277 – Spring 2002Notes 118 Definition Schedule S 1 is View Serializable if it is view equivalent to some serial schedule

9 CS 277 – Spring 2002Notes 119 View Conflict Serializable ? View Serializable  Conflict Serializable e.g., See Schedule Q Conflict Serializable  View Serializable ?

10 CS 277 – Spring 2002Notes 1110 Lemma Conflict Serializable  View Serializable Proof: Swapping non-conflicting actions does not change what transactions read nor final DB state

11 CS 277 – Spring 2002Notes 1111 Venn Diagram All schedules View Serializable Conflict Serializable

12 CS 277 – Spring 2002Notes 1112 Note: All view serializable schedules that are not conflict serializable, involve useless write S = W 2 (A) … W 3 (A)….. no reads

13 CS 277 – Spring 2002Notes 1113 How do we test for view-serializability?  P(S) not good enough… (see schedule Q)

14 CS 277 – Spring 2002Notes 1114 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 this write exists

15 CS 277 – Spring 2002Notes 1115 Another problem: useless writes S = …..W 2 (A)…….. W 1 (A)….. no A reads

16 CS 277 – Spring 2002Notes 1116 To check if S is View Serializable (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 CS 277 – Spring 2002Notes 1117 (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 CS 277 – Spring 2002Notes 1118 (3) Create labeled precedence graph of S: (3a) If w i (A)  r j (A) in S, add T i  T j 0

19 CS 277 – Spring 2002Notes 1119 (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 CS 277 – Spring 2002Notes 1120 (4) Check if LP(S) is “acyclic” (if so, S is V-S) - For each pair of “p” arcs (p  0), choose one

21 CS 277 – Spring 2002Notes 1121 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 CS 277 – Spring 2002Notes 1122 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 )

23 CS 277 – Spring 2002Notes 1123 S s =w b (A)r 1 (A)w 1 (A)w 2 (A)r 3 (A)w 3 (A)r f (A) T 1 T 2 T 3 Z + S s indeed do same thing

24 CS 277 – Spring 2002Notes 1124 Checking view serializability is expensive Still, V-S useful in some cases...

25 CS 277 – Spring 2002Notes 1125 Example on useless transactions: S = w 1 (A) r 2 (A) w 2 (B) r 1 (B) w 3 (A) w 3 (B)

26 CS 277 – Spring 2002Notes 1126 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

27 CS 277 – Spring 2002Notes 1127 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

28 CS 277 – Spring 2002Notes 1128 If all transactions read what they write, (I.e., T j=... R j (A) … W j (A)…) then view serializability = conf. serializability [Another way of saying: blind writes appear in any view-serializable schedule that is not conflict serializable]

29 CS 277 – Spring 2002Notes 1129 Proof(?): say S 1 is view-ser. and no blind writes. S 1 V-equiv to S s, serial schedule.

30 CS 277 – Spring 2002Notes 1130 Implications: If no blind writes, view-ser  conf-ser P(S) acyclic  all transactions read the same as in a serial schedule


Download ppt "CS 277 – Spring 2002Notes 111 CS 277: Database System Implementation Notes 11: View Serializability Arthur Keller."

Similar presentations


Ads by Google