Transactions and Concurrency Control
Transactions and Concurrency Control
1. Consider three data items D1, D2 and D3 and D3 and the following execution schedule of
transactions T1, T2 and T3. In the diagram, R(D) and W(D) denotes the actions reading and
writing the data item D respectively.
T1 T2 T3
R(D3);
R(D2);
W(D2);
R(D2);
R(D3);
R(D1);
W(D1);
R(D1);
R(D2);
W(D2);
W(D1);
(a) The schedule is serializable as T2; T3; T1 (b) The schedule is serializable as T2; T1; T3
(c) The schedule is serializable as T3; T2; T1 (d) The schedule is not serializable
read(x);
x:= x-50;
write(x);
read(y);
y:=y+50;
write(y);
The constraint that the sum of the accounts x and y should remain constant is that of:
3. Consider a simple checkpointing protocol and the following set of operations in the log:
(start, T4); (write, T4, y, 2, 3); (start, T1); (commit, T4); (write, T1, z, 5, 7); (checkpoint);
1
(start, T2); (write, T2, x, 1, 9); (commit, T2); (start, T3); (write, T3, z, 7, 2);
If a crash happens now and the system tries to recover using both undo and redo operation,
what are the contents of the undo list and the redo list?
(a) Undo: T3, T1, Redo: T2 (b) Undo: T3, T1; Redo: T2, T4
(c) Undo: none, Redo: T1, T2, T3, T4 (d) Undo: T3, T1, T4: Redo: T2
4. Consider the following partial schedule S involving 2 transactions T1 and T2. Only the read
and write operations have been shown. The read operation on data item P is denoted by r(P)
and write by w(P):
Transaction_id
Time
T1 T2
1 r(A)
2 w(A)
3 r(C)
4 w(C)
5 r(B)
6 w(B)
7 r(A)
8 Commit
9 r(B)
Suppose that the transaction T1 fails immediately after time instance 9. Which one of the
following statements is correct?
(a) T2 must be aborted and then both T1 and T2 must be restarted to ensure transaction
atomicity
(b) Schedule S is non-recoverable and cannot ensure transaction atomicity
(c) Only T2 must be aborted and then restarted to ensure transaction atomicity
(d) Schedule S is recoverable and can ensure atomicity and nothing else needs to be done
5. How many concurrent schedules can be formed with 3 transactions having 3, 2, 1 operations?
2
S2: R3(z), W2(x), W2(y), R1(x), R3(x), R2(z), R3(y), W1(x)
S3: R2(z), W2(x), W2(y), W1(x), R1(x), R3(x), R3(z), R3(y)
(a) S1 (b) S2
(c) S1, S2 (d) None of these
S: r1(a), r2(b), w2(a), w2(b),w3(a), r3(c), w3(b), r1(c), w4(b), w3(c), r4(a), r4(c), w4(c); commit1,
commit2, commit3, commit4
10. The time stamp of 2 transactions T1 and T2 are 10 and are 10 and 15 respectively. Consider
the following with T1 and T2 operations.
3
(a) S holds in Basic time stamp protocol (b) S holds under Thomas Write rule
(c) S holds under Multiversion time stamp (d) None of these
11. Consider the following log information that involves 3 transactions. Assume checkpoint is
used for crash recovery. The order of transactions are shown below:
12. Fill the missing entry for the intention lock model:
4
13. Which problem among the following is encountered in the given schedule?
T1 T2
R(A)
R(B)
B=A
W(B)
R(A)
A= A+10
W(A)
Commit
R(A)
R(C)
C=A
W(C)
T1 T2
R(A)
R(B)
R(C)
R(A)
R(B)
P:___
Q:___
R(C)
The possible values of P and Q allowed under Thomas Write Rule but not under basic time
stamp ordering protocol if TS(T2) > TS(T1)
5
15. Consider the following tree and locking sequence:
Which of the following is the valid locking sequence for true based protocol?
T1 T2
R(A)
A=A+10
R(B)
A=B+10
W(A)
R(B)
B=B+10
R(A)
B=A+10
W(B)
Commit
Commit
6
17. The precedence graph of a schedule with 3 transactions T1, T2, T3 is:
(a) r1(A); w2(A); w1(A); w3(A) (b) r1(A); w2(A); w3(A); w1(A)
(c) r1(A); w3(A); w2(A); w1(A) (d) None of these