Transaction Processing Recovery Concurrency Control.ppt
《Transaction Processing Recovery Concurrency Control.ppt》由会员分享,可在线阅读,更多相关《Transaction Processing Recovery Concurrency Control.ppt(44页珍藏版)》请在麦多课文档分享上搜索。
1、Transaction Processing Recovery & Concurrency Control,What is a transaction,A transaction is the basic logical unit of execution in an information system. A transaction is a sequence of operations that must be executed as a whole, taking a consistent ( A collection of actions that make consistent tr
2、ansformations of system states while preserving system consistency An indivisible unit of processing,database in a consistent state,database in a consistent state,database may be temporarily in an inconsistent state during execution,begin Transaction,end Transaction,execution of Transaction,Account
3、A Fred Bloggs 1000,Account B Sue Smith 0,Account B Sue Smith 500,Account A Fred Bloggs 500,Transfer 500,Desirable Properties of ACID Transactions,A Atomicity: a transaction is an atomic unit of processing and it is either performed entirely or not at all C Consistency Preservation: a transactions co
4、rrect execution must take the database from one correct state to another I Isolation/Independence: the updates of a transaction must not be made visible to other transactions until it is committed (solves the temporary update problem) D Durability (or Permanency): if a transaction changes the databa
5、se and is committed, the changes must never be lost because of subsequent failure o Serialisability: transactions are considered serialisable if the effect of running them in an interleaved fashion is equivalent to running them serially in some order,Requirements for Database Consistency,Concurrency
6、 Control Most DBMS are multi-user systems. The concurrent execution of many different transactions submitted by various users must be organised such that each transaction does not interfere with another transaction with one another in a way that produces incorrect results. The concurrent execution o
7、f transactions must be such that each transaction appears to execute in isolation. Recovery System failures, either hardware or software, must not result in an inconsistent database,Transaction as a Recovery Unit,If an error or hardware/software crash occurs between the begin and end, the database w
8、ill be inconsistent Computer Failure (system crash) A transaction or system error Local errors or exception conditions detected by the transaction Concurrency control enforcement Disk failure Physical problems and catastrophes The database is restored to some state from the past so that a correct st
9、ateclose to the time of failurecan be reconstructed from the past state. A DBMS ensures that if a transaction executes some updates and then a failure occurs before the transaction reaches normal termination, then those updates are undone. The statements COMMIT and ROLLBACK (or their equivalent) ens
10、ure Transaction Atomicity,Recovery,Mirroring keep two copies of the database and maintain them simultaneouslyBackup periodically dump the complete state of the database to some form of tertiary storageSystem Logging the log keeps track of all transaction operations affecting the values of database i
11、tems. The log is kept on disk so that it is not affected by failures except for disk and catastrophic failures.,Recovery from Transaction Failures,Catastrophic failure Restore a previous copy of the database from archival backup Apply transaction log to copy to reconstruct more current state by redo
12、ing committed transaction operations up to failure point Incremental dump + log each transaction Non-catastrophic failure Reverse the changes that caused the inconsistency by undoing the operations and possibly redoing legitimate changes which were lost The entries kept in the system log are consult
13、ed during recovery. No need to use the complete archival copy of the database.,Transaction States,For recovery purposes the system needs to keep track of when a transaction starts, terminates and commits. Begin_Transaction: marks the beginning of a transaction execution; End_Transaction: specifies t
14、hat the read and write operations have ended and marks the end limit of transaction execution (but may be aborted because of concurrency control); Commit_Transaction: signals a successful end of the transaction. Any updates executed by the transaction can be safely committed to the database and will
15、 not be undone; Rollback (or Abort): signals that the transaction has ended unsuccessfully. Any changes that the transaction may have applied to the database must be undone; Undo: similar to ROLLBACK but it applies to a single operation rather than to a whole transaction; Redo: specifies that certai
16、n transaction operations must be redone to ensure that all the operations of a committed transaction have been applied successfully to the database;,Entries in the System Log,For every transaction a unique transaction-id is generated by the system. start_transaction, transaction-id: the start of exe
17、cution of the transaction identified by transaction-idread_item, transaction-id, X: the transaction identified by transaction-id reads the value of database item X. Optional in some protocols. write_item, transaction-id, X, old_value, new_value: the transaction identified by transaction-id changes t
18、he value of database item X from old_value to new_valuecommit, transaction-id: the transaction identified by transaction-id has completed all accesses to the database successfully and its effect can be recorded permanently (committed)abort, transaction-id: the transaction identified by transaction-i
19、d has been aborted,Credit_labmark (sno NUMBER, cno CHAR, credit NUMBER) old_mark NUMBER; new_mark NUMBER; SELECT labmark INTO old_mark FROM enrol WHERE studno = sno and courseno = cno FOR UPDATE OF labmark; new_ mark := old_ mark + credit;UPDATE enrol SET labmark = new_mark WHERE studno = sno and co
20、urseno = cno ;COMMIT;EXCEPTION WHEN OTHERS THEN ROLLBACK;END credit_labmark;,active,partially,committed,committed,failed,terminated,BEGIN,TRANSACTION,READ,WRITE,END,TRANSACTION,ROLLBACK,ROLLBACK,COMMIT,Transaction execution,A transaction reaches its commit point when all operations accessing the dat
21、abase are completed and the result has been recorded in the log. It then writes a commit, transaction-id.,If a system failure occurs, searching the log and rollback the transactions that have written into the log a start_transaction, transaction-id write_item, transaction-id, X, old_value, new_value
22、 but have not recorded into the log a commit, transaction-id,Read and Write Operations of a Transaction,Specify read or write operations on the database items that are executed as part of a transaction read_item(X): reads a database item named X into a program variable also named X. 1. find the addr
23、ess of the disk block that contains item X 2. copy that disk block into a buffer in the main memory 3. copy item X from the buffer to the program variable named write_item(X): writes the value of program variable X into the database item named X. 1. find the address of the disk block that contains i
24、tem X 2. copy that disk block into a buffer in the main memory 3. copy item X from the program variable named X into its current location in the buffer store the updated block in the buffer back to disk (this step updates the database on disk),X,X:=,Checkpoints in the System Log,A checkpoint record
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- TRANSACTIONPROCESSINGRECOVERYCONCURRENCYCONTROLPPT

链接地址:http://www.mydoc123.com/p-373444.html