Page 163 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 163

X(A)
                                             R(A)
                                             A: = A-100;   T1                         T2
                                             W(A)
                                             X (B)
                                             R(B)
          Database Management Systems/Managing Database
                                             B: = B + 100;
                                             W (B)
                                             Commit
                    Notes                                                 X(A)
                                                                          R(A)
                                                                          A: = A + 0.06 A;
                                                                          W(A)
                                                                          X(B)
                                                                          R(B)
                                                                          B: = B + 0.06B;
                                                                          W(B)
                                                                          Commit

                                   Schedule Illustrating Strict 2PL with Serial Execution

                                   Moreover, the following figure illustrates a schedule following Strict 2PL with interleaved
                                   actions, where shared lock on A can only read A, but cannot write A and both T  and T  can hold
                                                                                                  1    2
                                   shared lock at the same time whereas an exclusive lock on B and C can both read and write the
                                   respective B and C but an exclusive lock cannot be held at the same time, instead an exclusive
                                   lock must hold each data item serially one after the other.

                                                          T1                          T2
                                            S(A)
                                            R(A)
                                                                         S(A)
                                                                         R(A)
                                                                         X(B)
                                                                         R(B)
                                                                         W(B)
                                                                         Commit
                                            X(C)
                                            R(C)
                                            W(C)
                                            Commit



                                      Task       Process to test serializability.

                                   9.10 Timestamp based Protocol

                                   In lock-based concurrency control, conflicting actions of different transactions are ordered by
                                   the order in which locks are obtained, and the lock protocol extends this ordering on actions to
                                   transactions, thereby ensuring serializability. In optimistic concurrency control, a timestamp
                                   ordering is imposed on transactions, and validation checks that all conflicting actions occurred
                                   in the same order.

                                   Timestamps can also be used in another way: each transaction can be assigned a timestamp at
                                   startup, and we can ensure, at execution time, that if action  a  of transaction T  conflicts with
                                                                                     i             i
                                   action a  of transaction T , ai occurs before a  if TS(T ) < TS(T ). If an action violates this ordering,
                                         j            j              j     i      j
                                   the transaction is aborted and restarted.



          156                               LOVELY PROFESSIONAL UNIVERSITY
   158   159   160   161   162   163   164   165   166   167   168