版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、Chapter 15: Transactions Chapter 15: TransactionsTransaction ConceptTransaction StateConcurrent ExecutionsSerializabilityRecoverabilityTransaction ConceptA transaction is a unit of program execution that accesses and possibly updates various data items.A transaction must see a consistent database.Du
2、ring transaction execution the database may be temporarily inconsistent.When the transaction completes successfully (is committed), the database must be consistent.After a transaction commits, the changes it has made to the database persist, even if there are system failures. Multiple transactions c
3、an execute in parallel.Two main issues to deal with:Failures of various kinds, such as hardware failures and system crashesConcurrent execution of multiple transactionsACID PropertiesAtomicity. Either all operations of the transaction are properly reflected in the database or none are.Consistency. E
4、xecution of a transaction in isolation preserves the consistency of the database.Isolation. Although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions. Intermediate transaction results must be hidden from other concurrently
5、executed transactions. That is, for every pair of transactions Ti and Tj, it appears to Ti that either Tj, finished execution before Ti started, or Tj started execution after Ti finished.Durability. After a transaction completes successfully, the changes it has made to the database persist, even if
6、there are system failures. A transaction is a unit of program execution that accesses and possibly updates various data items.To preserve the integrity of data the database system must ensure:Example of Fund TransferTransaction to transfer $50 from account A to account B:1.read(A)2.A := A 503.write(
7、A)4.read(B)5.B := B + 506.write(B)Atomicity requirement if the transaction fails after step 3 and before step 6, the system should ensure that its updates are not reflected in the database, else an inconsistency will result. Consistency requirement the sum of A and B is unchanged by the execution of
8、 the transaction.Example of Fund Transfer (Cont.)Isolation requirement if between steps 3 and 6, another transaction is allowed to access the partially updated database, it will see an inconsistent database (the sum A + B will be less than it should be).Isolation can be ensured trivially by running
9、transactions serially, that is one after the other. However, executing multiple transactions concurrently has significant benefits, as we will see later.Durability requirement once the user has been notified that the transaction has completed (i.e., the transfer of the $50 has taken place), the upda
10、tes to the database by the transaction must persist despite failures.Transaction StateActive the initial state; the transaction stays in this state while it is executingPartially committed after the final statement has been executed.Failed - after the discovery that normal execution can no longer pr
11、oceed.Aborted after the transaction has been rolled back and the database restored to its state prior to the start of the transaction. Two options after it has been aborted:restart the transaction; can be done only if no internal logical errorkill the transactionCommitted after successful completion
12、.Transaction State (Cont.)Implementation of Atomicity and DurabilityThe recovery-management component of a database system implements the support for atomicity and durability.The shadow-database scheme:assume that only one transaction is active at a time.a pointer called db_pointer always points to
13、the current consistent copy of the database.all updates are made on a shadow copy of the database, and db_pointer is made to point to the updated shadow copy only after the transaction reaches partial commit and all updated pages have been flushed to disk.in case transaction fails, old consistent co
14、py pointed to by db_pointer can be used, and the shadow copy can be deleted.Implementation of Atomicity and Durability (Cont.)Assumes disks do not failBetter schemes can be seen in Chapter 17.The shadow-database scheme:Concurrent ExecutionsMultiple transactions are allowed to run concurrently in the
15、 system. Advantages are:increased processor and disk utilization, leading to better transaction throughput: one transaction can be using the CPU while another is reading from or writing to the diskreduced average response time for transactions: short transactions need not wait behind long ones.Concu
16、rrency control schemes mechanisms to achieve isolation; that is, to control the interaction among the concurrent transactions in order to prevent them from destroying the consistency of the databaseWill study in Chapter 16, after studying notion of correctness of concurrent executions.SchedulesSched
17、ule a sequences of instructions that specify the chronological order in which instructions of concurrent transactions are executeda schedule for a set of transactions must consist of all instructions of those transactionsmust preserve the order in which the instructions appear in each individual tra
18、nsaction.A transaction that successfully completes its execution will have a commit instructions as the last statement (will be omitted if it is obvious)A transaction that fails to successfully complete its execution will have an abort instructions as the last statement (will be omitted if it is obv
19、ious)Schedule 1Let T1 transfer $50 from A to B, and T2 transfer 10% of the balance from A to B. A serial schedule in which T1 is followed by T2:Schedule 2 A serial schedule where T2 is followed by T1Schedule 3Let T1 and T2 be the transactions defined previously. The following schedule is not a seria
20、l schedule, but it is equivalent to Schedule 1.In Schedules 1, 2 and 3, the sum A + B is preserved.Schedule 4The following concurrent schedule does not preserve the value of (A + B).Assuming: before: A=B=100;How about after?SerializabilityBasic Assumption Each transaction preserves database consiste
21、ncy.Thus serial execution of a set of transactions preserves database consistency.A (possibly concurrent) schedule is serializable if it is equivalent to a serial schedule. Different forms of schedule equivalence give rise to the notions of:1.conflict serializability2.view serializabilityWe ignore o
22、perations other than read and write instructions, and we assume that transactions may perform arbitrary computations on data in local buffers in between reads and writes. Our simplified schedules consist of only read and write instructions.Conflicting Instructions Instructions li and lj of transacti
23、ons Ti and Tj respectively, conflict if and only if there exists some item Q accessed by both li and lj, and at least one of these instructions wrote Q. 1. li = read(Q), lj = read(Q). li and lj dont conflict. 2. li = read(Q), lj = write(Q). They conflict. 3. li = write(Q), lj = read(Q). They conflic
24、t 4. li = write(Q), lj = write(Q). They conflictIntuitively, a conflict between li and lj forces a (logical) temporal order between them. If li and lj are consecutive in a schedule and they do not conflict, their results would remain the same even if they had been interchanged in the schedule.Confli
25、ct SerializabilityIf a schedule S can be transformed into a schedule S by a series of swaps of non-conflicting instructions, we say that S and S are conflict equivalent.We say that a schedule S is conflict serializable if it is conflict equivalent to a serial scheduleConflict Serializability (Cont.)
26、Schedule 3 can be transformed into Schedule 6, a serial schedule where T2 follows T1, by series of swaps of non-conflicting instructions. Therefore Schedule 3 is conflict serializable.Schedule 3Schedule 6Conflict Serializability (Cont.)Example of a schedule that is not conflict serializable:We are u
27、nable to swap instructions in the above schedule to obtain either the serial schedule , or the serial schedule .Recoverable SchedulesRecoverable schedule if a transaction Tj reads a data item previously written by a transaction Ti , then the commit operation of Ti appears before the commit operation
28、 of Tj.The following schedule (Schedule 11) is not recoverable if T9 commits immediately after the readIf T8 should abort, T9 would have read (and possibly shown to the user) an inconsistent database state. Hence, database must ensure that schedules are recoverable.Need to address the effect of tran
29、saction failures on concurrently running transactions.Cascading RollbacksCascading rollback a single transaction failure leads to a series of transaction rollbacks. Consider the following schedule where none of the transactions has yet committed (so the schedule is recoverable)If T10 fails, T11 and
30、T12 must also be rolled back.Can lead to the undoing of a significant amount of workCascadeless SchedulesCascadeless schedules cascading rollbacks cannot occur; for each pair of transactions Ti and Tj such that Tj reads a data item previously written by Ti, the commit operation of Ti appears before
31、the read operation of Tj.Every cascadeless schedule is also recoverableIt is desirable to restrict the schedules to those that are cascadelessConcurrency ControlA database must provide a mechanism that will ensure that all possible schedules are either conflict or view serializable, and are recovera
32、ble and preferably cascadelessA policy in which only one transaction can execute at a time generates serial schedules, but provides a poor degree of concurrencyGoal to develop concurrency control protocols that will assure serializability.Weak Levels of ConsistencySome applications are willing to live with weak levels of consistency, allowing schedules that are not serializableE.g.
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 6495.7-2025光伏器件第7部分:光伏器件測量的光譜失配修正計算方法
- 貨運車輛黑名單制度
- 財務(wù)會計準(zhǔn)則制度
- 落實備案審查年度工作報告制度
- 2026福建南平市建陽區(qū)文化體育和旅游局招聘1人參考考試試題附答案解析
- 2026黑龍江雙鴨山公益性崗位招聘176人參考考試試題附答案解析
- 上海市執(zhí)法類公務(wù)員招錄體能測評健康承諾書備考考試題庫附答案解析
- 2026上半年云南事業(yè)單位聯(lián)考能源職業(yè)技術(shù)學(xué)院招聘21人參考考試題庫附答案解析
- 2026四川廣安市廣安區(qū)白市鎮(zhèn)人民政府選用片區(qū)紀(jì)檢監(jiān)督員1人備考考試題庫附答案解析
- 2026年云南師范大學(xué)基礎(chǔ)教育集團(tuán)人才招聘(若干)參考考試題庫附答案解析
- 技術(shù)規(guī)范評審匯報
- GB/T 462-2023紙、紙板和紙漿分析試樣水分的測定
- 不組織不參與非法集資承諾書
- 2023春國開農(nóng)業(yè)經(jīng)濟基礎(chǔ)單元自測1-16試題及答案
- 2023年高鐵信號車間副主任述職報告
- GB/T 879.4-2000彈性圓柱銷卷制標(biāo)準(zhǔn)型
- GB/T 1957-2006光滑極限量規(guī)技術(shù)條件
- GB 28480-2012飾品有害元素限量的規(guī)定
- 劉一秒演說智慧經(jīng)典(內(nèi)部筆記)
- 管道TOFD檢測記錄及續(xù)表
- 馬克思主義哲學(xué)精講課件
評論
0/150
提交評論