Chap 15
Chap 15
file systems would not be willing to pay the price (monetary, disk space, time)
of supporting ACID properties.
15.5 During its execution, a transaction passes through several states, until it finally
commits or aborts. List all possible sequences of states through which a trans-
action may pass. Explain why each state transition may occur.
Answer: The possible sequences of states are:-
a. active → partially committed → committed. This is the normal sequence a suc-
cessful transaction will follow. After executing all its statements it enters
the partially committed state. After enough recovery information has been
written to disk, the transaction finally enters the committed state.
b. active → partially committed → aborted. After executing the last statement
of the transaction, it enters the partially committed state. But before enough
recovery information is written to disk, a hardware failure may occur de-
stroying the memory contents. In this case the changes which it made to
the database are undone, and the transaction enters the aborted state.
c. active → failed → aborted. After the transaction starts, if it is discovered at
some point that normal execution cannot continue (either due to internal
program errors or external errors), it enters the failed state. It is then rolled
back, after which it enters the aborted state.
15.7 Explain the distinction between the terms serial schedule and serializable sched-
ule.
Answer: A schedule in which all the instructions belonging to one single trans-
action appear together is called a serial schedule. A serializable schedule has a
weaker restriction that it should be equivalent to some serial schedule. There
are two definitions of schedule equivalence – conflict equivalence and view
equivalence. Both of these are described in the chapter.
T1 : read(A);
read(B);
if A = 0 then B := B + 1;
write(B).
T2 : read(B);
read(A);
if B = 0 then A := A + 1;
write(A).
Answer:
a. There are two possible executions: T1 T2 and T2 T1 .
Case 1: A B
initially 0 0
after T1 0 1
after T2 0 1
Consistency met: A = 0 ∨ B = 0 ≡ T ∨ F = T
Case 2: A B
initially 0 0
after T2 1 0
after T1 1 0
Consistency met: A = 0 ∨ B = 0 ≡ F ∨ T = T
b. Any interleaving of T1 and T2 results in a non-serializable schedule.
T1 T2
T4 T3
T5
T1 T2
read(A)
read(B)
read(A)
read(B)
if A = 0 then B = B + 1
if B = 0 then A = A + 1
write(A)
write(B)
c. There is no parallel execution resulting in a serializable schedule. From
part a. we know that a serializable schedule results in A = 0 ∨ B = 0. Sup-
pose we start with T1 read(A). Then when the schedule ends, no matter
when we run the steps of T2 , B = 1. Now suppose we start executing T2
prior to completion of T1 . Then T2 read(B) will give B a value of 0. So
when T2 completes, A = 1. Thus B = 1 ∧ A = 1 → ¬ (A = 0 ∨ B = 0).
Similarly for starting with T2 read(B).
15.9 Since every conflict-serializable schedule is view serializable, why do we em-
phasize conflict serializability rather than view serializability?
Answer: Most of the concurrency control protocols (protocols for ensuring
that only serializable schedules are generated) used in practise are based on
conflict serializability—they actually permit only a subset of conflict serializ-
able schedules. The general form of view serializability is very expensive to
test, and only a very restricted form of it is used for concurrency control.
15.10 Consider the precedence graph of Figure 15.18. Is the corresponding schedule
conflict serializable? Explain your answer.
Answer: There is a serializable schedule corresponding to the precedence
graph below, since the graph is acyclic. A possible schedule is obtained by
doing a topological sort, that is, T1 , T2 , T3 , T4 , T5 .
T1 T2
T4 T3
T5