Suppose that the following locking protocol is followed: Every transaction begins byobtaining a shared lock on each data object that it needs to read and an exclusivelock on each data object that it needs to modify, and then releases all its locks aftercompleting all actions. Consider two transactionsT1 andT2 such thatT1 wants tomodify a data object andT2 wants to read the same object. Intuitively, ifT1’s requestfor an exclusive lock on the object is granted first,T2 cannot proceed untilT1 releasesthis lock, becauseT2’s request for a shared lock will not be granted by the DBMSuntil then. Thus, all ofT1’s actions will be completed before any ofT2’s actions areinitiated. We consider locking in more detail in Chapters 18 and 19.1.7.2Incomplete Transactions and System CrashesTransactions can be interrupted before running to completion for a variety of reasons,e.g., a system crash. A DBMS must ensure that the changes made by such incompletetransactions are removed from the database.For example, if the DBMS is in themiddle of transferring money from account A to account B, and has debited the firstaccount but not yet credited the second when the crash occurs, the money debitedfrom account A must be restored when the system comes back up after the crash.To do so, the DBMS maintains alogof all writes to the database.A crucial prop-erty of the log is that each write action must be recorded in the log (on disk)beforethe corresponding change is reflected in the database itself—otherwise, if the systemcrashes just after making the change in the database but before the change is recordedin the log, the DBMS would be unable to detect and undo this change. This propertyis calledWrite-Ahead LogorWAL. To ensure this property, the DBMS must beable to selectively force a page in memory to disk.The log is also used to ensure that the changes made by a successfully completedtransaction are not lost due to a system crash, as explained in Chapter 20. Bringingthe database to a consistent state after a system crash can be a slow process, sincethe DBMS must ensure that the effects of all transactions that completed prior to thecrash are restored, and that the effects of incomplete transactions are undone.Thetime required to recover from a crash can be reduced by periodically forcing someinformation to disk; this periodic operation is called acheckpoint.
18Chapter 11.7.3Points to NoteIn summary, there are three points to remember with respect to DBMS support forconcurrency control and recovery:1. Every object that is read or written by a transaction is first locked in shared orexclusive mode, respectively. Placing a lock on an object restricts its availabilityto other transactions and thereby affects performance.2. For efficient log maintenance, the DBMS must be able to selectively force a collec-tion of pages in main memory to disk. Operating system support for this operationis not always satisfactory.
Upload your study docs or become a
Course Hero member to access this document
Upload your study docs or become a
Course Hero member to access this document
End of preview. Want to read all 932 pages?
Upload your study docs or become a
Course Hero member to access this document