Written Problems - Spatial Database Group

advertisement
CSci 5708: Architecture and Implementation of Database Systems
Homework 3
Due date: 4/07
Maximum Points: 100
Note: Following notation is used for Question 1 and Question 2:
r1(X) – Read operation performed on data item X by transaction 1.
w2(Y) – Write operation performed on data item Y by transaction 2.
Question 1
(20 Points)
Consider schedules Sa, Sb, and Sc below. Determine whether each schedule is strict, cascade-less, recoverable,
or non-recoverable. (Determine the strictest recoverability condition that each schedule satisfies).
Sa: r1(x); r2(z); r1(z); r3(x); r3(y); w1(x); w3(y); c1; r2(y); w2(z); w2(y);c2;c3;
Sb: r1(x); r2(z); r1(z); w1(x); r3(y); r3(x); w3(y); r2(y); w2(z); w2(y); c1; c3; c2;
Sc: r1(x); w1(x); c1; r2(z); r3(y); w2(z); w3(y); c2; r5(z); c3; r4(y); w5(z); w4(y);a4;c5;
Sd: r1(x); r2(y); w1(x); c1; r2(x); w2(y); c2; r3(x); r3(z); w3(z); c3;
Question 2
(20 Points)
Consider three transactions T1, T2, and T3, and the schedules S1 and S2 given below. Draw conflict
serializability (precedence) graphs for S1 and S2, and determine conflict-serializability of each schedule. If a
schedule is serializable, list an equivalent serial schedule.
T1: r1 (X); w1 (X); r1 (Z);
T2: r2 (Y); r2 (Z); w2 (Z); w2 (Y);
T3: r3 (X); r3 (Y); r3 (Z); w3 (Y);
S1: r1(X); r2(Y); w1(X); r3(X); r3(Y); r1(Z); r3(Z); w3(Y); r2(Z); w2(Z); w2(Y);
S2: r1 (X); r2 (Y); r3 (X); w1 (X); r2 (Z); r1 (Z); w2 (Z); w2 (Y); r3(Y); r3(Z); w3(Y);
Question 3
(20 Points)
a) Is the schedule in Table 1 compatible with the time stamp ordering Concurrency Control technique?
Assume transaction T1 arrives at time t=3, transaction T2 arrives at time t=1 and transaction T3 arrives at
time t=2.
b) Briefly justify your answer by drawing a conflict schedule graph and identifying offending conflicts (if
any).
Table 1: Schedule for Question 4
time
Log sequence number(LSN)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Transaction 1
Transaction 2
Read_Item(Z)
Read_Item(Y)
Write_Item(Y)
Transaction 3
Read_Item(Y)
Read_Item(Z)
Read_Item(X)
Write_Item(X)
Write_Item(Y)
Write_Item(Z)
Read_Item(X)
Read_Item(Y)
Write_Item(Y)
Write_Item(X)
Read_Item(Y)
Question 4
(20 Points)
Table 3 shows the log of operations from transactions T1, T2, T3 and T4 before a power failure. Suppose that
the DBMS uses the immediate update based recovery algorithm.
a) Is the schedule represented by the log in Table 3 recoverable (without rolling back any committed
transactions) ?
b) Describe the recovery process after a system restart. Specify which transactions are rolled back, which
operations in the log are redone and which operations (if any) are undone, and whether any cascading rollback
takes place. Show your answer in a tabular form shown below in Table 2:
Table 2: Summary answer.
Committed
transactions
Active
transactions
Redone
operations
Rolled back
transactions
Cascaded rollback
transactions
Undone
operations
Table 3: Log file retrieved for the Schedule for Question 5.
Log sequence number(LSN)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Schedule/(log of operations)
[Start_transaction, T1]
[read_item, T1, A]
[read_item, T1,D]
[write_item, T1, D, 20,25]
[Commit, T1]
[checkpoint]
[start_transaction, T2]
[read_item, T2, B]
[write_item, T2, B, 12, 18]
[Commit, T2]
[start_transaction, T4]
[read_item, T4, D]
[write_item, T4, D, 25, 15]
[start_transaction, T3]
[write_item, T3, C, 30, 40]
[write_item, T3, F, 45, 60]
[read_item T4, E]
[write_item, T4, E, 30, 20]
[commit, T4]
System Crash
Question 5
Repeat the above question using deferred update based recovery algorithm.
(20 Points)
Download