Beruflich Dokumente
Kultur Dokumente
Introduction
Cascading roll-back
As shown in partial schedule shown on next page each transaction
observers two-phase locking protocol.
Let us consider, if transaction T5 fails after the read(A,a) operation of
transaction of T7. Then, T5 must be rollback, which results into rollback
of T6 and T7 also. Because, transaction T6 and T7 reads the value of A
modified by transaction T5. Since transaction T5 fails and rollback, it
means that transaction T5 obtain the original value of A and cancels the
modified value of A, but the other transactions T6 and T7 process the
modified value of A and result into inconsistent state of database. In
order to obtain the consistent state of database transactions T6 and T7,
must also rollback and has to start again.
T8
read(A1,a1);
read(A2,a2);
…….
read(An,an);
……..
write(A1,a1);
Transaction T9 is defined as
T9
read(A1,a1);
read(A2,a2);
display(a1+a2);
If we follow two-phase locking protocol the transaction T8 must lock item A1 in
exclusive mode because it has to perform write operation on item A1. The other
transaction T9 which has to just read the value of A1 unable to get shared lock on item
A1 until T8 perform write operation on A1.Since, T8 needs an exclusive lock on A1
only at the end of its execution where it perform write operation on A1 ,it is better if T8
could initially lock A1 in shared mode and then could later change lock to exclusive
mode when it has to perform write operation and we could get more concurrency.
Because, then transaction T8 and T9 could access data item A1 and A2 simultaneously.
This observation leads us to a refinement of the basic two-phase locking protocol, in
which lock conversions are allowed. We shall provide a mechanism for upgrading a
shared lock to an exclusive lock, and downgrading an exclusive lock to a shared lock.
We denote conversion from shared to exclusive modes by upgrade, and from exclusive
to shared by downgrade. Lock conversion cannot be allowed to occur arbitrarily.
Upgrading can take place in only the growing phase, whereas downgrading can take
place in only the shrinking phase. Returning to our example, transactions T8 and T9
can run concurrently under the refined two-phase locking protocol, as shown in the
incomplete schedule given below where only some of the locking instructions are
shown.
♦ When a transaction Ti issues a read(Q) operation. It issue a lock-
S(Q) instruction followed by read(Q) instruction.