版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年剧本杀运营公司员工薪酬福利管理制度
- 机场灯光培训课件
- 基于核心素养的初中合唱团梯队建设与音乐课程评价研究教学研究课题报告
- 2025年废旧纺织品回收市场趋势行业报告
- 2025年光伏组件功率五年提升目标报告
- 工程塑料回收五年发展:再生利用与性能恢复2025年市场报告
- 在职辅警晋升面试题目及答案
- 事业编内部竞聘制度
- 骑乘电动车交通安全课件
- 2025-2030中央变频空调行业市场深度分析及发展策略研究报告
- 股东代为出资协议书
- 消防管道拆除合同协议
- 青少年交通安全法规
- 《数据统计分析课件》
- 2024压力容器设计审批考试题库 判断题
- OWASP LLM人工智能网络安全与治理清单(中文版)
- 钻机检验表格
- GB/T 44143-2024科技人才评价规范
- 河南省洛阳市2023-2024学年高二上学期期末考试英语试题(解析版)
- JGT124-2017 建筑门窗五金件 传动机构用执手
- 大学德语四级词汇
评论
0/150
提交评论