




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Yunsheng Liu,Software College, HUST 2012. 11,V. Transaction,Processing,Yunsheng Liu,2,Deposit ( amount, account# ) x= read( account# ); write( account#, amount+x) Consider: account# = 125, amount=2000 T1: Deposit (10000, 125) T2: Deposit (100, 125) How about the result of the DB if concurrently exec
2、ute the transactions without any control ?,1. Example,5.1 Transaction Management Concepts,Yunsheng Liu,3,2. Transaction Concept Def. A transaction is a set of tasks that each performs a logical function in a DB application,5.1 Transaction Management Concepts,3. The Properties of Transactions,Atomici
3、ty : Failure Atomicity/Reliability,Consistency: Concurrency Atomicity/Correctness,Isolation: Execution Atomicity/Serializability,Durability: Result persistence/permanence,Yunsheng Liu,4,- Each of the transactions in the system must be in one of the following states:,4. The States of Transactions,Sub
4、mitted before acquiring resources required Ready waiting for schedule Active being in the interval of BEGIN, and COMMIT/ABORT ,5.1 Transaction Management Concepts,Yunsheng Liu,5,Failed the normal execution can no longer proceed Aborted after having been undone(previous DB state) Committed Ended - In
5、tegrity, Security, Consistency.,5.2.3 The Major Tasks,Yunsheng Liu,10,5.3 Concurrency Control,5.3.1 Introduction 1. Concept - The activities to deal with what can go wrong because of interleaving of transactions in the absence of failures. 2. Assumption - If transactions are serially executed until
6、completion, then:,they produce correct results; they presents the consistency of the DB.,3. Notations: Wi(x, v), Ri(x), Ci, Ai,Yunsheng Liu,11,1. Write-Write Problem -lost update - Example: DB:(x, 0); T: t1, t2,5.3.2 Problems of Interleaving,The transactions are correct, but the result incorrect,DB=
7、(x,100),Yunsheng Liu,12,2. Read-Write Problem-unrepeatable read (1) Example: DB=(x,0), T=t1, t2 ,1,5.3.2 Problems of Interleaving,Yunsheng Liu,13,3. Write-Read Problem-read dirty data Example: HT t1 t2 1 a=R2(x) 2 b=R2(y) 3 c= R1(y) 4 W2(x, a+b) 5 d=R1(x) 6 W1(z, c+d) 7 C2/A2 8 ,What will be happed
8、?,Yunsheng Liu,14,-Three Typical Concurrency /Inconsistency Problems (1). Lost updateWi (x) Wj(x) history: W-W prob. (2). Dirty dataWi (x) Rj(x) history: W-R prob. (3). Unrepeatable readRi (x) Wj(x) history: R-W prob.,5.3.2 Problems of Interleaving,Yunsheng Liu,15,5.3.3 Serialization,Yunsheng Liu,16
9、,Serializability Theorem: - A history HT is SR iff the SG(HT) is acyclic,Test Algorithm for serializability of a HT,3. A Graphical Serializability Test,Example: T= t1: R1(x)W1(x)C1; t2: R2(x) R2(y) W2(x) C2; t3: R3(y)W3(y)C3; ,5.3.3 Serialization,Yunsheng Liu,17, HTR1(x)R2(x)W1(x)R2(y)C1W2(x)R3(y)C2
10、W3(y)C3 SG(HT), HTR1(x)W1(x)R2(x)R2(y)C1W2(x)R3(y)C2W3(y)C3 SG(HT),5.3.3 Serialization,Yunsheng Liu,18,5.4 Lock Mechanisms, Associated with each data item in a DB Always associated with an op. of a transaction,Lock an access privilege to a single data item, which the Lock Manager grant or which hold
11、 from a transaction.,5.4 .1 Basic Concepts,Lock Types: SLt(x), XLt(x), ULt(x),Any transaction that requires a lock which conflicts with another lock has to wait until another releases,Yunsheng Liu,19,4. Lock compatibility: the same as that of Ops.,5.4 .1 Basic Concepts,Yunsheng Liu,20,5.4.2 Basic Tw
12、o-Phase Locking (2PL),1. CC Mechanism,Yunsheng Liu,21,2. 2PL-Protocol - In any transaction all lockings must precede all unlockings.,(1) Protocola restriction on sequences of transaction operations. (2) Growing/Locking Phase - Whenever a Pt (x) received, the CC grants a PLt(x) if it is available, an
13、d then Pt (x) can be executed. (3) Shrinking/Unlocking Phase - Once a transaction has already released a lock, the CC doesnt allow the transaction to obtain any lock,5.4.2 Basic Two-Phase Locking (2PL),Yunsheng Liu,22,5.4.3 Lock Table( LT),Yunsheng Liu,23,5.4.4 Implementation of Locking,2PL Mechanis
14、m,Yunsheng Liu,24,5.5 Recovery Processing,1. The Concept - To restore the DB to a state that is known to be correct after some failure has rendered the current state incorrect.,5.5.1. Introduction,2. The Tasks 1) During a normal execution of a transaction T do: - logging. - Checkpointing - Backup Co
15、pying.,Yunsheng Liu,25,2).When T commits - Make the effects of T permanent in the DB - Logging the commit 3). When T aborts - Obliterate the effects on other transactions that read the(dirty) data written by T. - Obliterate any updates on data in the DB by T. - Logging the abort 4). When some failur
16、e occurs . - Bring the DB (system) to its recent consistent state.,5.5.1. Introduction,Yunsheng Liu,26,1.Transaction Failures - No data lost - An unplanned /abnormal program termination by,5.5.2 Failure Types,Logical errors Bad inputs Unavailable data Resource limits, e.g. deadlocks User cancellatio
17、ns.,Yunsheng Liu,27,2.System Failures - volatile storage data lost - A system stop caused by some events:,HW malfunctions bug in OS power failures Operators errors,5.5.2 Failure Types,Yunsheng Liu,28,4.Unrecoverable failures - Failures that make archive/backup dumps damaged. - Destructions of archiv
18、es.,disk head Crash. disk controller failure data transfer errors,3.Media failures - NV-storage data lost. - A failure in which a non-Volatile storage is physically damaged.,5.5.2 Failure Types,Yunsheng Liu,29,5.5.3 Logging,Transaction records Operation records Data change records,Yunsheng Liu,30,5.5.4 Checkpointing,Physically force-write the log buffer out to the archive log on disk Physically force-write a “cpt record” out to the archive log Physically force-write the DB buffer out to the DB Write the address of the “cpt reco
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 朱子誦讀比賽活動(dòng)方案
- 林業(yè)與草原科技活動(dòng)方案
- 朗誦大賽活動(dòng)方案
- 注冊(cè)稅務(wù)師高新培訓(xùn)課件
- 注冊(cè)會(huì)計(jì)師稅務(wù)課件
- 集中采購(gòu)分配方案
- 2025至2030IPL(強(qiáng)脈沖光)脫毛行業(yè)市場(chǎng)占有率及投資前景評(píng)估規(guī)劃報(bào)告
- 2025-2030阻燃布行業(yè)市場(chǎng)發(fā)展分析及投資前景研究報(bào)告
- 昭通市義診活動(dòng)方案
- 春茶落地活動(dòng)方案
- 光纖通信系統(tǒng)(第3版) 課件 第1-3章 概述、光纖與光纜、光源和光發(fā)送機(jī)
- 貸款車電子合同模板
- 高空作業(yè)車外墻施工方案
- GB/T 150.3-2024壓力容器第3部分:設(shè)計(jì)
- 拼多多店鋪代運(yùn)營(yíng)合同模板
- 體育訓(xùn)練館維修改造工程鋼結(jié)構(gòu)網(wǎng)架屋面施工組織設(shè)計(jì)
- 機(jī)動(dòng)車安全技術(shù)檢驗(yàn)操作規(guī)范標(biāo)準(zhǔn)
- 電化學(xué)儲(chǔ)能黑啟動(dòng)技術(shù)導(dǎo)則
- MOOC 計(jì)算機(jī)網(wǎng)絡(luò)-華南理工大學(xué) 中國(guó)大學(xué)慕課答案
- 工程經(jīng)濟(jì)學(xué)(第6版)全套教學(xué)課件
- 陜西史上最全的2024屆數(shù)學(xué)七年級(jí)第二學(xué)期期末綜合測(cè)試試題含解析
評(píng)論
0/150
提交評(píng)論