CS340 Databases (Quiz- 6)Solution Name:________________________ Reg#:___________________ Question 1 (5+5 =10 points) a. Draw a precedence graph to find whether the given schedule is serializable or not? If yes, then write the serialized schedule. R1(A), R2(A), R3(C), W3(C), R2(B), W2(B), R1(B), R4(B),R1(C), R4(C),W4(B) Conflicting Operations W3(C) ---- R1(C) W3(C) ---- R4(C) R2(B) ---- W4(B) W2(B) ---- R1(B) W2(B) ---- R4(B) W2(B) ---- W4(B) R1(B) ---- W4(B) T1 T2 T3 T4 Serializable as there is no cycle Possible schedules: T3 , T2, T1, T4 T2 , T3, T1, T4 b. For the schedule given above, what transactions will commit (if any) if the concurrency is ensured using Time Stamp Ordering (TSO) protocol? What will be the final value of Read(RTS)/Write(WTS) timestamp for each data object? Assume initial time stamps of transactions as follows, TS(Ti) = i, i.e. TS(T1) = 1 R1(A), R2(A), R3(C), W3(C), R2(B), W2(B), R1(B), R4(B),R1(C), R4(C),W4(B) T1 = 1, T2 = 2, T3 = 3, T4 =4 A RTS 0 1. 1 2. 2 WTS 0 B 0 5. 2 8. 4 0 6. 2 7. Rollback T1 11. 4 Ignore 9. R1(c), T1 is already rolled back C 0 3. 3 10. 4 0 4. 3 Question 3 (1+1+1+2 = 5) Consider the schedule (on the right) with exclusive(X) and shared (S) lock requests, where T1 is the oldest and T3 is the youngest transaction. The oldest transaction has the highest priority. Answer the following: Time 1 2 3 4 5 6 7 8 T1 X(D) T2 T3 X(A) S(A) S(B) S(B) S(C) X(B) S(D) S(C) a. Suppose we are not using any deadlock avoidance algorithms. Write the time in the schedule above in which the lock request could not have been made. Time 3 (T1) and 7(T3) T1 blocked at 3 as it is not granted shared lock on A. T2 already has exclusive lock on A. T3 is blocked on 7, it will not be granted an upgrade(exclusive lock) on B as another transaction T2 has shared lock on this b. What is the first time when deadlock will occur? Time 8 c. Which transaction(s) are involved in the first deadlock. T1 (waiting for A) and T2 (waiting for D) d. With the wound-wait deadlock avoidance algorithm, what would happen at time 3? a. The transaction requesting the lock would wait b. The transaction requesting the lock would abort c. The transaction that holds the lock would abort