版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《GB 18243-2008塑性体改性沥青防水卷材》专题研究报告
- 《DZT 0448-2023滑坡崩塌泥石流灾害精细调查规范》专题研究报告深度
- 2026年中国地质大学(北京)郑州研究院招聘备考题库带答案详解
- 《DLT 1851-2018发电厂钢制衬胶管道和管件》专题研究报告
- 2026年考试题用友数据顾问专业能力测试
- 2026年中国科学院水土保持科学与工程学院招聘备考题库完整参考答案详解
- 2026年软件工程师面试题库及编程能力测试含答案
- 2026年腾讯产品经理面试题及审计要点
- 2026年禁毒知识竞赛220题及答案
- 2026年网络工程师岗位面试题集与答案解析
- 中图版地理七年级上册知识总结
- 大连理工大学固态相变各章节考点及知识点总节
- 肿瘤科专业组药物临床试验管理制度及操作规程GCP
- 统编版四年级下册语文第二单元表格式教案
- 测量系统线性分析数据表
- 上海农贸场病媒生物防制工作标准
- 第三单元课外古诗词诵读《太常引·建康中秋夜为吕叔潜赋》课件
- YY 0334-2002硅橡胶外科植入物通用要求
- GB/T 5836.1-1992建筑排水用硬聚氯乙烯管材
- 论文写作讲座课件
- 危险化学品-培训-课件
评论
0/150
提交评论