



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Question 1 [20 points]. Conflict Serializability
Consider the following schedule involving three transactions T1, T2 and T3:
(a) Draw the precedence graph for this schedule.
(b) Is this schedule conflict serializable? Why or why not? If it is conflict serializable, give the
equivalent serial schedule (just write the order of the transactions).
(c) Write down all instances where one transaction “reads from” another transaction.
(If T2 reads from T1, write T1 → T2.)
Now swap the 4
th
and 5
th
actions in the schedule.
(d) Is the new schedule conflict serializable? Why or why not? If it is conflict serializable, give
the equivalent serial schedule (just write the order of the transactions).
Answer:
(a) 8 pts
(b) 2 pts
No, because the precedence graph has a cycle between T1 and T3.
(c) 4 pts
(d) 6 pts
Yes. Now the precedence graph is acyclic.
And an equivalent serial schedule is:
Question 2 [10 points]. Serializability and Recoverability
Consider the following classes of schedules: serializable , conflict-serializable , recoverable ,
avoids-cascading-aborts (same as cascadeless ), and strict. For each of the following schedules,
state which of the preceding classes it belongs to.
(It is important to note that serializability concerns only committed transactions while
recoverability concerns both committed and aborted transactions. )
The actions are listed in the order they are scheduled and prefixed with the transaction name.
(a) T1:R(A), T2:W(A), T1:W(A), T2:Abort, T1:Commit
(b) T1:W(A), T2:R(A), T1:W(A), T2:Commit, T1:Commit
Answer: (5 points each)
(a) It is serializable, conflict-serializable;
It is recoverable and avoids cascading aborts;
It is not strict.
(b) It is not serializable, not conflict-serializable;
It is not recoverable, therefore not avoid cascading aborts, not strict.
Question 3 [40 points]. Concurrency Control Protocols
Consider the following sequences of actions, listed in the order they are submitted to the DBMS:
T1: R(A) W(B) (Commit)
T2: W(A) W(B) (Commit)
T3: W(B) (Commit)
For each sequence and for each of the following concurrency control mechanisms, describe how
the concurrency control mechanism handles the sequence. Assume that the timestamp of
transaction Ti is i. For lock-based concurrency control mechanisms, add lock and unlock
requests to the previous sequence of actions as per the locking protocol. The DBMS processes
actions in the order shown. If a transaction is blocked, assume that all its actions are queued until
it is resumed; the DBMS continues with the next action (according to the listed sequence) of an
unblocked transaction.
In optimistic CC, each transaction executes by reading values from the database and writing to a
private workspace. Each transaction then acquires a timestamp when entering the validation
phase. The timestamp of transaction Ti is i.
Since T1 gets the earliest timestamp, it will commit without problem. But when validating T
against T1, none of the three conditions hold, so T2 will be aborted and restarted later. So is T
(same as T2).
(d) Recall that nonstrict 2PL can start to release locks after it has acquired all locks needed. To
answer this question, we need to find the earliest point when a transaction can release (some of)
its locks. For this schedule,
T1 first gets an S lock on A.
T2 blocks when trying to get an X lock on B.
T3 gets an X lock on B and then an X lock on C.
After the 1
st
W(C), T3 can releases the X lock on B (because the lock on B is no longer needed
and T3 has acquired all its locks).
So T1 can acquire its S lock on B.
Then T3 aborts, so T1 also has to abort.
So, cascading aborts can occur when using nonstrict 2PL.
Question 4 [30 points]. ARIES recovery algorithm
Consider the execution shown in the figure above.
(a) What is the value of the LSN stored in the master log record?
(b) What is done during Analysis?
(c) What is done during Redo?
(d) What is done during Undo?
Answer :
a) [2 pts] LSN 00 is stored in the master log record as it is the LSN of the begin checkpoint
record.
(b) [14 pts] We use TT to denote the transaction table and DPT to denote the dirty page table.
During analysis the following happens:
LSN 10 | Add (T2,10) to TT and (P3,10) to DPT
LSN 15 | Add (T3,15) to TT and (P1,15) to DPT
LSN 20 | Add (T1,20) to TT and (P2,20) to DPT
LSN 25 | Change status of T3 to C
LSN 30 | Change (T1,20) to (T1,30)
LSN 35 | Remove T3 from TT
LSN 40 | Change (T2,10) to (T2,40) and add (P4,40) to DPT
LSN 45 | Change (T1,30) to (T1,45)
At the end of analysis,
be used in UNDO.
This table will be used in REDO.
(c) [5 pts] Redo starts from LSN10 (minimum recLSN in DPT).
LSN 10 | Redo the change to P3.
LSN 15 | Redo the change in P1.
LSN 20 | Redo the change in P2.
LSN 25 | No action
LSN 30 | Redo the change in P1.
LSN 35 | No action
LSN 40 | Redo the changes in P4.
LSN 45 | No action
(d) [9 pts] ToUndo initially consists of (40,45) for the two loser transactions T1 and T2.
LSN 45 | add LSN 30 to the loser set for T1.