香港科技大学:Transaction Management、Serializability Theory and Concurrency Control、Lock-Based Protocols、Deadlock Problems、Recovery

Transaction Management Department of Computer Science and Engineering, HKUST 1
Department of Computer Science and Engineering, HKUST 1 Transaction Management

Introduction Time sharing systems executes more than one program at the same time by interleaving the execution of the programs In DBMS we consider transactions, not programs a transaction is a database program that must be completed entirely in order to retain the consistency of the database if the transaction cannot be completed the database should remain at the same state as if the transaction hadn 't been executed at all if the database is initially in consistent state(or empty), a sequence of transactions would bring the database from one consistent state to another Concerned only with interleaved execution of transactions Department of Computer Science and Engineering, HKUST 2
Department of Computer Science and Engineering, HKUST 2 • Time sharing systems executes more than one program at the same time by interleaving the execution of the programs • In DBMS, we consider transactions, not programs • A transaction is a database program that must be completed entirely in order to retain the consistency of the database; if the transaction cannot be completed, the database should remain at the same state as if the transaction hadn’t been executed at all • Concerned only with interleaved execution of transactions Introduction If the database is initially in consistent state (or empty), a sequence of transactions would bring the database from one consistent state to another

Assumptions and Basic operations a database is a set of data items accessed and modified by transactions o a transaction accesses or modifies the contents of a database 口 read item(x)orR(X): Reads a database itemⅩ a write_item(X)or W(X): Writes a value into the database item X a Additional operations Commit- the transaction is successful and the data items value must be changed(if any) on the database permanently Rollback/Abort- the transaction is not successful, do not change any of the data values BEGIN TRANSACTION, END TRANSACTION a data item x could be. An attribute DBMS may need UNDO and REDO for database recovery. A column A row A page(of tuples) A table Department of Computer Science and Engineering, HKUST 3
Department of Computer Science and Engineering, HKUST 3 • A database is a set of data items accessed and modified by transactions • A transaction accesses or modifies the contents of a database read_item(X) or R(X): Reads a database item X write_item(X) or W(X): Writes a value into the database item X Additional operations: – Commit - the transaction is successful and the data items value must be changed (if any) on the database permanently – Rollback/Abort - the transaction is not successful, do not change any of the data values – BEGIN_TRANSACTION, END_TRANSACTION DBMS may need UNDO and REDO for database recovery Assumptions and Basic Operations A data item X could be: • An attribute • A column • A row • A page (of tuples) • A table

Correctness Requirement of Transactions a database state consists of the complete set of data values in the database a database state is consistent if the database obeys all the integrity constrain a transaction brings the database from one consistent state to another consistent state whether or not The transaction is executed alone or concurrently with other transactions Failures occur in any transaction during its execution Database in a Database may be temporarily in an Database in a consistent state inconsistent state during execution consistent state Execution of transaction Begin Transaction End transaction Department of Computer Science and Engineering, HKUST 4
Department of Computer Science and Engineering, HKUST 4 • A database state consists of the complete set of data values in the database • A database state is consistent if the database obeys all the integrity constraint • A transaction brings the database from one consistent state to another consistent state, whether or not: • The transaction is executed alone or concurrently with other transactions • Failures occur in any transaction during its execution Database in a consistent state Database may be temporarily in an inconsistent state during execution Database in a consistent state Begin Transaction End Transaction Correctness Requirement of Transactions Execution of Transaction

States of a Transaction Read/rite transaction.( active transaction, Partially-commit committed committed abort failed terminated Active: transaction is started and is issuing reads and writes to the database Partially committed: operations are done and values are ready to be written to the database Committed: writing to the database is permitted and successfully completed Abort: the transaction or the system detects a fatal error Terminated: transaction leaves the system Department of Computer Science and Engineering, HKUST 5
Department of Computer Science and Engineering, HKUST 5 Active: transaction is started and is issuing reads and writes to the database Partially committed: operations are done and values are ready to be written to the database Committed: writing to the database is permitted and successfully completed Abort: the transaction or the system detects a fatal error Terminated: transaction leaves the system active Partially committed failed terminated committed Begin transaction End transaction commit abort abort Read/Write States of a Transaction

Other Properties of a Transaction Incomplete transactions cannot reveal its results to other transactions before commitment Committed updates are persistent (won't be lost) Once a transaction commits, the system must guarantee that the results of its operations will never be lost(database recovery) Department of Computer Science and Engineering, HKUST 6
Department of Computer Science and Engineering, HKUST 6 Other Properties of a Transaction • Incomplete transactions cannot reveal its results to other transactions before commitment • Committed updates are persistent (won’t be lost) • Once a transaction commits, the system must guarantee that the results of its operations will never be lost (database recovery)

Requirements on the DBMS o maintain database consistency over time(consistency atomicity) To ensure multiple users can simultaneously access and modify the data without creating inconsistency(isolation) To make the changes to data permanent (durability) Consistency atomicity and durability are needed even if transactions are executed serially (i.e. no interleaving) Department of Computer Science and Engineering, HKUST 7
Department of Computer Science and Engineering, HKUST 7 • To maintain database consistency over time (consistency, atomicity) • To ensure multiple users can simultaneously access and modify the data without creating inconsistency (isolation) • To make the changes to data permanent (durability) • Consistency, atomicity and durability are needed even if transactions are executed serially (i.e., no interleaving) Requirements on the DBMS

Why is Concurrency Control Needed? Several problems occur when concurrent transactions execute in an uncontrolled manner A sChedule of concurrent transactions is a particular sequence of interleaving of their read or write operations In general a transaction, has a set of data items it accesses (read set), and a set of data items it modifies( write set Department of Computer Science and Engineering, HKUST 8
Department of Computer Science and Engineering, HKUST 8 • Several problems occur when concurrent transactions execute in an uncontrolled manner • A schedule of concurrent transactions is a particular sequence of interleaving of their read or write operations • In general a transaction, has a set of data items it accesses (read set), and a set of data items it modifies (write set) Why is Concurrency Control Needed?

Problem 1: Lost Update Problem a transaction overwrites a data item modified by other transactions Transaction 1(HK ATM) Transaction 2(KIn ATm) RI(Balance) R2 Balance Balance=Balance +500 Balance=Balance-700 W1(Balance) W2(Balance) Schedule 1 Balance Schedule 2 Balance RI(Balance) 1000 RI(Balance) 1000 R2(Balance) 1000 R2(Balance) 1000 WI(Balance) 1500 W2(Balance) 300 overwrite W2( Balance) 300 WI(Balance) 1500 overwrite The correct(consistent)value of Balance is 800, when initial Balance is 1000 Department of Computer Science and Engineering, HKUST 9
Department of Computer Science and Engineering, HKUST 9 A transaction overwrites a data item modified by other transactions The correct (consistent) value of Balance is 800, when initial Balance is 1000 Transaction 1 (HK ATM) R1(Balance) Balance=Balance + 500 W1(Balance) Transaction 2 (Kln ATM) R2(Balance) Balance=Balance - 700 W2(Balance) Schedule 1 Balance R1(Balance) 1000 R2(Balance) 1000 W1(Balance) 1500 W2(Balance) 300 Schedule 2 Balance R1(Balance) 1000 R2(Balance) 1000 W2(Balance) 300 W1(Balance) 1500 Problem 1: Lost Update Problem overwrite overwrite

Problem 2: Dirty Read a transaction reads uncommitted modified data item values updated by other transactions Transaction 1(HK ATM) Transaction 2(KIn ATM) RI(Balance) R2 Balance) Balance=Balance +500 Balance=Balance-1200 WI(Balance) W2( Balance) abort Commit Schedule RI(Balance) 1000 T2 read a wIBalance) 1500 For a consistent database ction dirty value also be aborted from t1 W2(Balance) 300 Abort tl Commit t2 300 Department of Computer Science and Engineering, HKUST 10
Department of Computer Science and Engineering, HKUST 10 A transaction reads uncommitted modified data item values updated by other transactions. For a consistent database state, Transaction 2 should also be aborted Transaction 1 (HK ATM) R1(Balance) Balance=Balance + 500 W1(Balance) Abort Transaction 2 (Kln ATM) R2(Balance) Balance=Balance -1200 W2(Balance) Commit Schedule R1(Balance) 1000 W1(Balance) 1500 R2(Balance) 1500 W2(Balance) 300 Abort T1 Commit T2 300 Problem 2: Dirty Read T2 read a “dirty value” from T1
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 沈阳理工大学:《计算机网络技术及应用》课程教学资源(PPT课件讲稿)第一章 互联网与网站 Interent & Website(主讲:廉哲).ppt
- 西安电子科技大学:《计算机网络 Computer Networks》课程教学资源(PPT课件讲稿)第六章 应用层.pptx
- 《物联网技术导论》课程教学资源(PPT讲稿)Continuous Scanning with Mobile Reader in RFID Systems - an Experimental Study.pptx
- 《机器学习》课程教学资源(PPT课件讲稿)第10讲 决策树.ppt
- Flexible Online Task Assignment in Real-Time Spatial Data.pptx
- 北京大学:《项目成本管理》课程教学资源(PPT课件讲稿)质量管理计划(主讲:周立新).ppt
- Efficient Algorithms for Optimal Location Queries in Road Networks.ppt
- 《计算机网络》课程教学资源(PPT课件讲稿,第三版)Chapter 04 网络层 Network Layer.ppt
- 《电子商务概论》课程教学资源(PPT课件讲稿)第7章 电子商务与物流.ppt
- 《网络算法学》课程教学资源(PPT课件讲稿)第四章 原则的运用.ppt
- 清华大学:计算机科学与技术(PPT讲稿)组播 Multicast.pptx
- 《机器学习》课程教学资源(PPT课件讲稿)第七章 贝叶斯分类器 MACHINE LEARNING.pptx
- 西安电子科技大学:《计算机网络 Computer Networks》课程教学资源(PPT课件讲稿)第五章 传输层.pptx
- 清华大学:不确定型决策(PPT讲稿)Decision Making under Uncertainty.pptx
- 《Computer Networking:A Top Down Approach》英文教材教学资源(PPT课件讲稿,4th edition)Chapter 1 Introduction.ppt
- 《神经网络和模糊系统》课程教学资源(PPT讲稿)第四章 突触动力学、非监督学习.ppt
- 南京航空航天大学:《C++》课程电子教案(PPT课件讲稿)第4章 类的高级部分.ppt
- 西安电子科技大学:《计算机网络 Computer Networks》课程教学资源(PPT课件讲稿)概述(主讲:岳鹏).ppt
- 计算机语言的学科形态与发展历程(PPT课件讲稿).ppt
- 西安电子科技大学:《计算机网络 Computer Networks》课程教学资源(PPT课件讲稿)第一章 概述(主讲:马涛).pptx
- 《大学计算机基础》课程电子教案(PPT教学课件)第5章 多媒体技术基础.ppt
- 中国科学院:超级计算平台Linux初级培训(PPT讲稿,2009.11).ppt
- Routing in Vehicular Ad Hoc Network(PPT课件讲稿).ppt
- Linux操作系统初级培训(PPT讲稿)DSC认证培训体系.ppt
- Linux操作系统使用(PPT讲稿,简明基础教程,共七章).ppt
- 香港科技大学:Overviewof the Internet of Things(IoTs,PPT课件讲稿).ppsx
- 《C语言程序设计》课程教学资源(PPT课件讲稿)第3章 最简单的C程序设计.ppt
- 清华大学出版社:《C程序设计》课程PPT教学课件(第三版)第二章 程序的灵魂——算法.ppt
- 《数据库原理》课程教学资源(PPT课件讲稿)第五章 数据库的存储结构.ppt
- 《编译原理》课程教学资源(PPT课件讲稿)第六章 句法结构模式识别.ppt
- 中国科学技术大学:《并行计算 Parallel Computing》课程教学资源(PPT课件讲稿)图论补充内容.pptx
- 中央电大:《计算机组成原理》课程教学资源(PPT课件讲稿)教学辅导.ppt
- 《网站建设》课程教学资源(PPT课件讲稿)第五章 Javascript脚本语言.ppt
- 安徽工贸职业技术学院:《计算机组装与维护》课程教学资源(PPT课件讲稿)项目四 搭建微型计算机软件系统.ppt
- 《图像处理与计算机视觉 Image Processing and Computer Vision》课程教学资源(PPT课件讲稿)Chapter 07 Mean-shift and Cam-shift.pptx
- 华中科技大学:《操作系统原理》课程电子教案(PPT教学课件)第一章 绪论Principles of Operating System(主讲:郑然).ppt
- 西安电子科技大学:《信息系统安全》课程教学资源(PPT课件讲稿)第五章 操作系统安全、第六章 网络安全、第七章 应用安全、第八章 管理安全.ppt
- 武汉大学:《数据库系统概论》课程教学资源(PPT课件讲稿)第4章 关系数据库理论.ppt
- 并行算法概述(PPT课件讲稿).pptx
- 《计算机网络》课程教学资源(PPT讲稿)项目1 构建简单互连网络(Windows XP).ppt