![第14講-事務(wù)管理技術(shù)_第1頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/f4b502fa-d802-48b8-8e2f-2b795c818b0e/f4b502fa-d802-48b8-8e2f-2b795c818b0e1.gif)
![第14講-事務(wù)管理技術(shù)_第2頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/f4b502fa-d802-48b8-8e2f-2b795c818b0e/f4b502fa-d802-48b8-8e2f-2b795c818b0e2.gif)
![第14講-事務(wù)管理技術(shù)_第3頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/f4b502fa-d802-48b8-8e2f-2b795c818b0e/f4b502fa-d802-48b8-8e2f-2b795c818b0e3.gif)
![第14講-事務(wù)管理技術(shù)_第4頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/f4b502fa-d802-48b8-8e2f-2b795c818b0e/f4b502fa-d802-48b8-8e2f-2b795c818b0e4.gif)
![第14講-事務(wù)管理技術(shù)_第5頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/f4b502fa-d802-48b8-8e2f-2b795c818b0e/f4b502fa-d802-48b8-8e2f-2b795c818b0e5.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、課程名稱課程名稱: : 數(shù)據(jù)庫系統(tǒng)數(shù)據(jù)庫系統(tǒng) -A transaction is a unit of program execution that accesses and possibly updates various data items.A transaction must see a consistent database. During transaction execution the database may be temporarily inconsistent. When the transaction completes successfully (is committe
2、d), 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 can execute in parallel.Two main issues to deal with: Failures of various kinds,such as hardware failures and system crashes Conc
3、urrent execution of multiple transactions原子性原子性Atomicity. Either all operations of the transaction are properly reflected in the database or none are.一致性一致性Consistency. Execution of a transaction in isolation preserves the consistency of the database.隔離性隔離性Isolation. Although multiple transactions m
4、ay execute concurrently, each transaction must be unaware of other concurrently executing transactions. (Intermediate transaction results must be hidden from other concurrently executed transactions) That is, for every pair of transactions Ti and Tj , it appears to Ti that either Tj finished executi
5、on before Ti started, or Tj started execution after Ti finished.(即每個事務(wù)都感覺不到其它事務(wù)在并行執(zhí)行)持久性持久性Durability. After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures. To preserve the integrity of data the database system must ensure:Tra
6、nsaction to transfer $50 from account A to account B:1.read(A)2.A := A 503.write(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 re
7、sult. Consistency requirement the sum of A and B is unchanged by the execution of the transaction.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 b
8、e). Isolation can be ensured trivially by running 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.,
9、the transfer of the $50 has taken place), the updates to the database by the transaction must persist despite failures (after step 3 and before step 6).Active the initial state; the transaction stays in this state while it is executingPartially committed after the final statement has been executed.F
10、ailed - after the discovery that normal execution can no longer proceed.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 log
11、ical error kill the transactionCommitted after successful completion.Schedule a sequences of instructions that specify the chronological按時間順序排列的 order in which instructions of concurrent transactions are executed a schedule for a set of transactions must consist of all instructions of those transact
12、ions must preserve the order in which the instructions appear in each individual transaction.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
13、 will have an abort instructions as the last statement (will be omitted if it is obvious)Let 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: A serial schedule where T2 is followed by T1Let T1 and T2 be the transactions def
14、ined previously. The following schedule is not a serial schedule, but it is equivalent to Schedule 1.n In Schedules 1, 2 and 3, the sum A + B is preserved.n 合理轉(zhuǎn)賬The following concurrent schedule does not preserve the value of (A + B). 不合理轉(zhuǎn)賬Basic Assumption Each transaction preserves database consist
15、ency. 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: conflict serializability沖突可串行化 view serializability視圖可串行
16、化We ignore operations 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. And so our simplified schedules consist of only read and write instructions.沖突指令:沖突指令:Instructions li and lj of trans
17、actions 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 the two 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 co
18、nflict 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.沖
19、突等價:沖突等價:If 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 scheduleSchedule 3 can be transfor
20、med 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 6Example of a schedule that is not conflict serializable:We are unable to swap instructions in the above schedule to obtain
21、 either the serial schedule , or the serial schedule .Consider some schedule of a set of transactions T1, T2, ., Tn優(yōu)先圖Precedence graph a direct graph where the vertices are the transactions (names). We draw an arc from Ti to Tj if the two transaction conflict, and Ti accessed the data item on which
22、the conflict arose earlier. We may label the arc by the item that was accessed.xyPrecedence graphPrecedence graphT1 T2 T3 T4 T5read(X)read(Y)read(Z)read(V)read(W)read(W)read(Y)write(Y)write(Z)read(U)read(Y)write(Y)read(Z)write(Z)read(U)write(U)T3T4T1T2T5A schedule is conflict serializable if and onl
23、y if its precedence graph is acyclic.無環(huán)的Cycle-detection algorithms exist which take order n2 time, where n is the number of vertices in the graph. (Better algorithms take order n + e where e is the number of edges.)If precedence graph is acyclic, the serializability order can be obtained by a topolo
24、gical sorting拓?fù)渑判?of the graph. This is a linear order consistent with the partial order of the graph. For example, a serializability order for Schedule A would beT5 T1 T3 T2 T4 Are there others? T5T1T2T3T4 又例:又例:Recoverable schedule if a transaction Tj reads a data item previously written by a tran
25、saction Ti , then the commit operation of Ti appears before the commit operation of Tj.The following schedule (Schedule 11) is not recoverable if T9 commits immediately after the read 原因分析:If T8 should abort, T9 would have read (and possibly shown to the user) an inconsistent database state. Hence,
26、database must ensure that schedules are recoverable.Need to address the effect of transaction failures on concurrently running transactions.定義:Cascading rollback a single transaction failure leads to a series of transaction rollbacks. 例子:Consider the following schedule where none of the transactions
27、 has yet committed (so the schedule is recoverable)If T10 fails, T11 and T12 must also be rolled back.效果: It can lead to the undoing of a significant amount of workCascadeless schedules cascading rollbacks cannot occur; for each pair of transactions Ti and Tj , such that Tj reads a data item previou
28、sly written by Ti , the commit operation of Ti appears before the read operation of Tj . (若Tj讀了由Ti所寫的數(shù)據(jù),則Ti先于Tj提交)顯然:Every cascadeless schedule is also recoverableIt is desirable to restrict the schedules to those that are cascadeless可串行化:保證可串行化調(diào)度可重復(fù)讀:只允許讀取已提交數(shù)據(jù),且在一個事務(wù)兩次讀取一個數(shù)據(jù)項期間,其他事務(wù)不得更新該數(shù)據(jù)。已提交讀:只允
29、許讀取已提交數(shù)據(jù),但不要求可重復(fù)讀。未提交讀:允許讀取未提交數(shù)據(jù)。A database must provide a mechanism that will ensure that all possible schedules are either conflict or view serializable, and are recoverable and preferably cascadelessA policy in which only one transaction can execute at a time generates serial schedules, but provides a poor degree of concurrency Are serial schedules recoverable/cascadeless? 問題如何解決?提高事務(wù)并發(fā)執(zhí)行度! Testing a schedule for serializability after it has executed is a little
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 借款擔(dān)保人協(xié)議書
- 軟件開發(fā)和測試技術(shù)作業(yè)指導(dǎo)書
- 策劃推廣服務(wù)合同
- 數(shù)據(jù)挖掘與商業(yè)智能解決方案作業(yè)指導(dǎo)書
- XXX高校報告廳項目會議播音系統(tǒng)設(shè)計方案
- 農(nóng)業(yè)產(chǎn)業(yè)化環(huán)境保護(hù)方案
- 小學(xué)二年級數(shù)學(xué)上學(xué)期口算訓(xùn)練 打印版
- 2025年益陽貨運從業(yè)資格證模擬考試保過版
- 2025年貴陽貨運從業(yè)資格證考試模擬考試題庫答案解析
- 疼痛管理服務(wù)合同(2篇)
- 2025至2030年中國減肥肽數(shù)據(jù)監(jiān)測研究報告
- 2024內(nèi)蒙古公務(wù)員省直行測、行政執(zhí)法、省考行測考試真題(5套)
- 2025年安徽馬鞍山市兩山綠色生態(tài)環(huán)境建設(shè)有限公司招聘筆試參考題庫附帶答案詳解
- 山東省濱州市濱城區(qū)2024-2025學(xué)年九年級上學(xué)期期末考試化學(xué)試題
- 泳池翻新改造施工方案
- 國有企業(yè)內(nèi)部審計工作制度(2篇)
- 部編版《道德與法治》四年級下冊教材解讀與分析文檔
- 人教版八年級美術(shù)下冊全冊完整課件
- 化學(xué)魯科版必修一期末復(fù)習(xí)98頁P(yáng)PT課件
- 《農(nóng)產(chǎn)品質(zhì)量安全檢測》PPT課件
- 陳啟申的ERP概念與原理
評論
0/150
提交評論