




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Chapter 17: Recovery SystemChapter 17: Recovery SystemFailure ClassificationRecovery and AtomicityLog-Based RecoveryFailure ClassificationTransaction failure :Logical errors: transaction cannot complete due to some internal error conditionSystem errors: the database system must terminate an active t
2、ransaction due to an error condition (e.g., deadlock)System crash: a power failure or other hardware or software failure causes the system to crash.Fail-stop assumption: non-volatile storage contents are assumed to not be corrupted by system crashDatabase systems have numerous integrity checks to pr
3、event corruption of disk data Disk failure: a head crash or similar disk failure destroys all or part of disk storageDestruction is assumed to be detectable: disk drives use checksums to detect failuresRecovery AlgorithmsRecovery algorithms are techniques to ensure database consistency and transacti
4、on atomicity and durability despite failuresFocus of this chapterRecovery algorithms have two partsActions taken during normal transaction processing to ensure enough information exists to recover from failuresActions taken after a failure to recover the database contents to a state that ensures ato
5、micity, consistency and durabilityData AccessPhysical 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 physical block B
6、 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.We assume, for
7、 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.write(X) assigns
8、 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 first time; All subse
9、quent 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 AccessxYABx1y1 bufferBuffer Block A Buffer Block Binput(A)output(B) read(X)write(Y)diskwor
10、k areaof T1work areaof T2 memoryx2Recovery and AtomicityModifying 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 either to perform all database modification
11、s 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 failures, we first output information descr
12、ibing the modifications to stable storage without modifying the database itself.We study a approach:log-based recoveryWe assume (initially) that transactions run serially, that is, one after the other.Log-Based RecoveryA log is kept on stable storage. The log is a sequence of log records, and mainta
13、ins a record of update activities on the database.When transaction Ti starts, it registers itself by writing a log recordBefore Ti executes write(X), a log record is written, where V1 is the value of X before the write, and V2 is the value to be written to X.Log record notes that Ti has performed a
14、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 storage (that is, they are not buffered)Two approaches using logsDeferred d
15、atabase modificationImmediate database modificationDeferred Database ModificationThe deferred database modification scheme records all modifications to the log, but defers all the writes to after partial commit.Assume that transactions execute seriallyTransaction starts by writing record to log. A w
16、rite(X) operation results in a log record being written, where V is the new value for XNote: old value is not needed for this schemeThe write is not performed on X at this time, but is deferred.When Ti partially commits, is written to the log Finally, the log records are read and used to actually ex
17、ecute 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 ( redoTi) sets the value of all data items updated by the transaction to the new values.Cra
18、shes can occur while the transaction is executing the original updates, or while recovery action is being takenexample transactions T0 and T1 (T0 executes before T1):T0: read (A)T1 : read (C)A: - A - 50 C:-C- 100Write (A) write (C)read (B)B:- B + 50write (B)Deferred Database Modification (Cont.)Belo
19、w we show the log as it appears at three instances of time.If log on stable storage at time of crash is as in case:(a) No redo actions need to be taken(b) redo(T0) must be performed since is present (c) redo(T0) must be performed followed by redo(T1) since and are presentImmediate Database Modificat
20、ionThe immediate database modification scheme allows database updates of an uncommitted transaction to be made as the writes are issuedsince undoing may be needed, update logs must have both old value and new valueUpdate log record must be written before database item is writtenWe assume that the lo
21、g record is output directly to stable storageCan be extended to postpone log record output, so long as prior to execution of an output(B) operation for a data block B, all log records corresponding to items B must be flushed to stable storageOutput of updated blocks can take place at any time before
22、 or after transaction commitOrder in which blocks are output can be different from the order in which they are written.Immediate Database Modification ExampleLog Write OutputTo, B, 2000, 2050 A = 950 B = 2050 C = 600 BB, BC BANote: BX denotes block containing X.x1Immediate Database Modification (Con
23、t.)Recovery procedure has two operations instead of one: undo(Ti) restores the value of all data items updated by Ti to their old values, going backwards from the last log record for Tiredo(Ti) sets the value of all data items updated by Ti to the new values, going forward from the first log record
24、for TiBoth operations must be idempotentThat is, even if the operation is executed multiple times the effect is the same as if it is executed onceNeeded since operations may get re-executed during recovery When recovering after failure:Transaction Ti needs to be undone if the log contains the record
25、 , but does not contain the record .Transaction Ti needs to be redone if the log contains both the record and the record .Undo operations are performed first, then redo operations.Immediate DB Modification Recovery Example Below we show the log as it appears at three instances of time.Recovery actio
26、ns in each case above are:(a) undo (T0): B is restored to 2000 and A to 1000.(b) undo (T1) and redo (T0): C is restored to 700, and then A and B are set to 950 and 2050 respectively.(c) redo (T0) and redo (T1): A and B are set to 950 and 2050 respectively. Then C is set to 600CheckpointsProblems in
27、recovery procedure as discussed earlier :searching the entire log is time-consumingwe might unnecessarily redo transactions which have alreadyoutput their updates to the database.Streamline recovery procedure by periodically performing checkpointing Output all log records currently residing in main memory onto stable storage.Output all modified buffer blocks to the disk.Write a log record onto stable storage.Checkpoints (Cont.)During recovery we need to consider only the most recent transaction Ti that started before the checkpoint, and transactio
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 遵化薪酬福利管理办法
- 拆房项目现场管理办法
- 西藏房屋租赁管理办法
- 广告文印采购管理办法
- 产品培训课件封面图案
- 朗诵的培训的课件
- 肠梗阻内科护理课件
- 肝癌患者护理课件
- 恩施清外初中数学试卷
- 电脑改数学试卷
- DB3301T 0410-2023 城市河道生态清淤管理规范
- 9.1 浮力(课件)2024-2025学年沪粤版物理八年级下册
- 双碳知识培训
- 金融科技风险管理
- 大部分分校:地域文化形考任务一-国开(CQ)-国开期末复习资料
- 2025版国家开放大学法律事务专科《民法学(1)》期末考试总题库
- 2024年度软件开发合同功能需求规格说明书2篇
- DB52T 046-2018 贵州省建筑岩土工程技术规范
- 医疗保险基金使用监督管理条例
- 三家比价合同范例
- 《义务教育语文课程标准》(2022年版)
评论
0/150
提交评论