Page 159 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 159

Database Management Systems/Managing Database




                    Notes          Motivation for Concurrent Execution

                                   The schedule, involving two transactions shown in the following figure represents an interleaved
                                   execution of the two transactions.

                                                          T1                           T2
                                             R(A)
                                             W(A)
                                                                            R(B)
                                                                            W(B)
                                             R(C)
                                             W(C)

                                   First, while one transaction is waiting for a page to be read in from disk, the CPU can process
                                   another transaction This is because I/O activity can be done in parallel with CPU activity in a
                                   computer. Overlapping I/O and CPU activity reduces the amount of time and increases system
                                   throughput which is the average number of transactions completed in a given time.
                                   Second, interleaved execution of a short transaction with a long transaction usually allows the
                                   short transaction to complete quickly. In serial execution, a short transaction could get stuck
                                   behind a long transaction, leading to unpredictable delays in response, time, or average time
                                   taken to complete a transaction.

                                   9.5 Serializability


                                   A serializable schedule over a set S of committed transactions is a schedule whose effect on any
                                   consistent database is guaranteed to be identical to that of some complete serial schedule over S.
                                   That is, even-though the actions of transactions are interleaved, the result of executing transactions
                                   serially in different orders may produce different results.

                                   9.6 Recoverability

                                   Unfortunately,  the  timestamp  protocol  presented  above  permits  schedules  that  are  not
                                   recoverable, as illustrated by the schedule in Table  below. If TS(T ) = 1 and  TS(T )  = 2, this
                                                                                         1            2
                                   schedule is permitted by the timestamp protocol (with or without the Thomas Write Rule). The
                                   timestamp protocol can be modified to disallow such schedules by buffering all write actions
                                   until the transaction commits. In the example, when T  wants to write A, WTS(A) is updated to
                                                                              1
                                   reflect this action, but the change to A is not carried out immediately; instead, it is recorded in a
                                   private workspace, or buffer. When T  wants to read A subsequently, its timestamp is compared
                                                                2
                                   with WTS(A), and the read is seen to be permissible. However, T  is blocked until T  completes.
                                                                                       2             1
                                   If T  commits, its change to A is copied from the buffer; otherwise, the changes in the buffer are
                                     1
                                   discarded. T  is then allowed to read A.
                                             2
                                             T1                          T2
                                             W(A)
                                                                         R(A)
                                                                         W(B)
                                                                         Commit

                                   This blocking of T  is similar to the effect of T  obtaining an exclusive lock on A! Nonetheless,
                                                 2                      1
                                   even with this modification the timestamp protocol permits some schedules that are not permitted
                                   by 2PL; the two protocols are not quite the same.




          152                               LOVELY PROFESSIONAL UNIVERSITY
   154   155   156   157   158   159   160   161   162   163   164