Chapter 17- Recovery System.ppt
《Chapter 17- Recovery System.ppt》由会员分享,可在线阅读,更多相关《Chapter 17- Recovery System.ppt(71页珍藏版)》请在麦多课文档分享上搜索。
1、Chapter 17: Recovery System,Failure Classification Storage Structure Recovery and Atomicity Log-Based Recovery Shadow Paging Recovery With Concurrent Transactions Buffer Management Failure with Loss of Nonvolatile Storage Advanced Recovery Techniques ARIES Recovery Algorithm Remote Backup Systems,Fa
2、ilure Classification,Transaction failure : Logical errors: transaction cannot complete due to some internal error condition System errors: the database system must terminate an active transaction due to an error condition (e.g., deadlock) System crash: a power failure or other hardware or software f
3、ailure causes the system to crash. Fail-stop assumption: non-volatile storage contents are assumed to not be corrupted by system crash Database systems have numerous integrity checks to prevent corruption of disk data Disk failure: a head crash or similar disk failure destroys all or part of disk st
4、orage Destruction is assumed to be detectable: disk drives use checksums to detect failures,Recovery Algorithms,Recovery algorithms are techniques to ensure database consistency and transaction atomicity and durability despite failures Focus of this chapter Recovery algorithms have two parts Actions
5、 taken during normal transaction processing to ensure enough information exists to recover from failures Actions taken after a failure to recover the database contents to a state that ensures atomicity, consistency and durability,Storage Structure,Volatile storage: does not survive system crashes ex
6、amples: main memory, cache memory Nonvolatile storage: survives system crashes examples: disk, tape, flash memory, non-volatile (battery backed up) RAM Stable storage: a mythical form of storage that survives all failures approximated by maintaining multiple copies on distinct nonvolatile media,Stab
7、le-Storage Implementation,Maintain multiple copies of each block on separate disks copies can be at remote sites to protect against disasters such as fire or flooding. Failure during data transfer can still result in inconsistent copies: Block transfer can result in Successful completion Partial fai
8、lure: destination block has incorrect information Total failure: destination block was never updated Protecting storage media from failure during data transfer (one solution): Execute output operation as follows (assuming two copies of each block): Write the information onto the first physical block
9、. When the first write successfully completes, write the same information onto the second physical block. The output is completed only after the second write successfully completes.,Stable-Storage Implementation (Cont.),Protecting storage media from failure during data transfer (cont.): Copies of a
10、block may differ due to failure during output operation. To recover from failure: First find inconsistent blocks: Expensive solution: Compare the two copies of every disk block. Better solution: Record in-progress disk writes on non-volatile storage (Non-volatile RAM or special area of disk). Use th
11、is information during recovery to find blocks that may be inconsistent, and only compare copies of these. Used in hardware RAID systems If either copy of an inconsistent block is detected to have an error (bad checksum), overwrite it by the other copy. If both have no error, but are different, overw
12、rite the second block by the first block.,Data Access,Physical blocks are those blocks residing on the disk. Buffer blocks are the blocks residing temporarily in main memory. Block movements between disk and main memory are initiated through the following two operations: input(B) transfers the physi
13、cal block B to main memory. output(B) transfers the buffer block B to the disk, and replaces the appropriate physical block there. Each transaction Ti has its private work-area in which local copies of all data items accessed and updated by it are kept.Tis local copy of a data item X is called xi. W
14、e assume, for simplicity, that each data item fits in, and is stored inside, a single block.,Data Access (Cont.),Transaction transfers data items between system buffer blocks and its private work-area using the following operations : read(X) assigns the value of data item X to the local variable xi.
15、 write(X) assigns the value of local variable xi to data item X in the buffer block. both these commands may necessitate the issue of an input(BX) instruction before the assignment, if the block BX in which X resides is not already in memory. Transactions Perform read(X) while accessing X for the fi
16、rst time; All subsequent accesses are to the local copy. After last access, transaction executes write(X). output(BX) need not immediately follow write(X). System can perform the output operation when it deems fit.,Example of Data Access,x,Y,A,B,x1,y1,buffer,Buffer Block A,Buffer Block B,input(A),ou
17、tput(B),read(X),write(Y),disk,work area of T1,work area of T2,memory,x2,Recovery and Atomicity,Modifying the database without ensuring that the transaction will commit may leave the database in an inconsistent state. Consider transaction Ti that transfers $50 from account A to account B; goal is eit
18、her to perform all database modifications made by Ti or none at all. Several output operations may be required for Ti (to output A and B). A failure may occur after one of these modifications have been made but before all of them are made.,Recovery and Atomicity (Cont.),To ensure atomicity despite f
19、ailures, we first output information describing the modifications to stable storage without modifying the database itself. We study two approaches: log-based recovery, and shadow-paging We assume (initially) that transactions run serially, that is, one after the other.,Log-Based Recovery,A log is ke
20、pt on stable storage. The log is a sequence of log records, and maintains a record of update activities on the database. When transaction Ti starts, it registers itself by writing a log record Before Ti executes write(X), a log record is written, where V1 is the value of X before the write, and V2 i
21、s the value to be written to X. Log record notes that Ti has performed a write on data item Xj Xj had value V1 before the write, and will have value V2 after the write. When Ti finishes it last statement, the log record is written. We assume for now that log records are written directly to stable st
22、orage (that is, they are not buffered) Two approaches using logs Deferred database modification Immediate database modification,Deferred Database Modification,The deferred database modification scheme records all modifications to the log, but defers all the writes to after partial commit. Assume tha
23、t transactions execute serially Transaction starts by writing record to log. A write(X) operation results in a log record being written, where V is the new value for X Note: old value is not needed for this scheme The write is not performed on X at this time, but is deferred. When Ti partially commi
24、ts, is written to the log Finally, the log records are read and used to actually execute the previously deferred writes.,Deferred Database Modification (Cont.),During recovery after a crash, a transaction needs to be redone if and only if both and are there in the log. Redoing a transaction Ti ( red
25、oTi) sets the value of all data items updated by the transaction to the new values. Crashes can occur while the transaction is executing the original updates, or while recovery action is being taken example transactions T0 and T1 (T0 executes before T1):T0: read (A) T1 : read (C)A: - A - 50 C:- C- 1
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CHAPTER17RECOVERYSYSTEMPPT
