




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- T-ZSM 0049-2024“領(lǐng)跑者”評價技術(shù)要求 機(jī)織兒童服裝
- 二零二五年度高效節(jié)能大棚租賃及能源管理協(xié)議
- 二零二五年度個人環(huán)保項(xiàng)目貸款抵押擔(dān)保合同
- 二零二五年度汽車銷售區(qū)域代理退出協(xié)議
- 二零二五年度街道辦事處社區(qū)工作者績效激勵聘用合同
- 二零二五年度智能交通管理系統(tǒng)知識產(chǎn)權(quán)授權(quán)協(xié)議
- 2025年度車輛質(zhì)押融資服務(wù)協(xié)議
- 二零二五年度高新技術(shù)園區(qū)建設(shè)資金委托墊資合同
- 2025年度終止供貨協(xié)議函模板與合同終止后的利益平衡
- 企業(yè)采購管理流程改進(jìn)調(diào)研報告
- 2025年湖南工業(yè)職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫審定版
- 人教版高一下英語單詞表
- 如何做好實(shí)習(xí)生帶教
- 2025年中國游戲行業(yè)市場深度分析及發(fā)展前景預(yù)測報告
- 專項(xiàng)訓(xùn)練:電磁感應(yīng)中的電路、電荷量及圖像問題(10大題型)(原卷版)
- 汽車電腦故障解碼器項(xiàng)目可行性研究報告評審方案設(shè)計2025年發(fā)改委標(biāo)準(zhǔn)
- 國家文化安全教育課件
- 2025年春新滬粵版物理八年級下冊課件 7.2 運(yùn)動的快慢 速度
- 2025年人工智能技術(shù)研發(fā)與應(yīng)用合作協(xié)議9篇
- DG-T 110-2024 茶樹修剪機(jī)標(biāo)準(zhǔn)
- 外貿(mào)英語口語900句
評論
0/150
提交評論