版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
Chapter10
UpdateTransaction2022/12/23UpdateTransaction2ch10UpdateTransactionDef.10.1TransactionAtransactionisameanstopackagetogetheranumberofdatabaseoperationsperformedbyaprocess,sothedatabasesystemcanprovideseveralguarantees,calledtheACIDproperties.BEGINTRANSACTIONop1;op2;opN;ENDTRANSACTION2022/12/23UpdateTransaction3ch10UpdateTransactionBeginatransactionfirstdatabaseoperationEndatransactionbyexecutingBEGINTRANSACTIONop1;op2;opN;ENDTRANSACTIONexecsqlcommitwork;orexecsqlrollbackwork;2022/12/23UpdateTransaction4TransactionsManyenterprisesusedatabasestostoreinformationabouttheirstatee.g.,BalancesofalldepositorsatabankWhenaneventoccursintherealworldthatchangesthestateoftheenterprise,aprogramisexecutedtochangethedatabasestateinacorrespondingwaye.g.,BankbalancemustbeupdatedwhendepositismadeSuchaprogramiscalledatransaction2022/12/23UpdateTransaction5WhatDoesaTransactionDo?ReturninformationfromthedatabaseRequestBalancetransaction:Readcustomer’sbalanceindatabaseandoutputitUpdatethedatabasetoreflecttheoccurrenceofarealworldeventDeposittransaction:Updatecustomer’sbalanceindatabaseCausetheoccurrenceofarealworldeventWithdrawtransaction:Dispensecash(andupdatecustomer’sbalanceindatabase)2022/12/23UpdateTransaction6TransactionsTheexecution
ofeachtransactionmustmaintaintherelationshipbetweenthedatabasestateandtheenterprisestate2022/12/23UpdateTransaction7Example:bankingapplicationswithfilesystemproblemsCreatinganinconsistentresultErrorsofconcurrentexecutionUncertaintyastowhenchangesepermanent2022/12/23UpdateTransaction8Problems:CreatinganinconsistentresultOurapplicationistransferringmoneyfromoneaccounttoanother(differentpages).Oneaccountbalancegetsouttodisk(runoutofbufferspace)andthenthecomputercrashes.2022/12/23UpdateTransaction9problemsErrorsofconcurrentexecutionTeller1transfersmoneyfromAcctAtoAcctBofthesamecustomer,whileTeller2isperformingacreditcheckbyaddingbalancesofAandB.Teller2canseeAaftertransfersubtracted,Bbeforetransferadded.2022/12/23UpdateTransaction10problemsUncertaintyastowhenchangesepermanentAttheveryleast,wewanttoknowwhenitissafetohandoutmoney:don'twanttoforgetwediditifsystemcrashes,thenonlydataondiskissafe.2022/12/23UpdateTransaction11TransactionsThereforeadditionalrequirementsareplacedontheexecutionoftransactionsbeyondthoseplacedonordinaryprograms:AtomicityConsistencyIsolationDurabilityACIDproperties2022/12/23UpdateTransaction12Atomicity
(原子性)Thesetofrecordupdatesthatarepartofatransactionareindivisible(eithertheyallhappenornonehappen).Thisistrueeveninpresenceofacrash.Consistency
(一致性)Ifalltheindividualprocessesfollowcertainrules(moneyisneithercreatednordestroyed)andusetransactionsright,thentheruleswon'tbebrokenbyanysetoftransactionsactingtogether.2022/12/23UpdateTransaction13Isolation
(隔離性)MeansthatoperationsofdifferenttransactionsseemnottobeinterleavedintimeasifALLoperationsofoneTxbeforeorafteralloperationsofanyotherTy.Durability
(持久性)WhenthesystemreturnstothelogicafteraCommitWorkstatement,itguaranteesthatallTxUpdatesareondisk.NowATMmachinecanhandoutmoney.ACIDguarantees2022/12/23UpdateTransaction1410.1TransactionalHistoriesActionsinthedatabaseReadsandWritesofdataitemsRi(A):transactionwithidentificationnumberi(Ti)readsdataitemA.Wj(B):transactionTjwritesB.AUpdateStatementwillresultinalotofoperations:Rj(B1)Wj(B1)Rj(B2)Wj(B2)...Rj(Bn)Wj(Bn)2022/12/23UpdateTransaction15[10.1.2]
historyorschedule(調(diào)度)Figure10.1ThejoboftheSchedulerlookatthehistoryofoperationsasitcomesinandprovidetheIsolationguarantee,bysometimesdelayingsomeoperations,andoccasionallyinsistingthatsometransactionsbeaborted.R2(A,50)W2(A,20)R1(A,20)R1(B,50)R2(B,50)W2(B,80)C1C22022/12/23UpdateTransaction1610.1TransactionalHistoriesserialschedule(串行調(diào)度)alloperationsofaTxareperformedinsequencewithnointerleavingwithothertransactions.Schedulerassuresthatthesequenceofoperationsinhistoryisequivalentineffecttosomeserialschedule.2022/12/23UpdateTransaction17Example10.1.1ThetwoelementsAandBin(10.1.2)areaccountrecordswitheachhavingbalance50tobeginwith.T1isaddingupbalancesoftwoaccountsT2istransferring30unitsfromAtoBR2(A,50)W2(A,20)R1(A,20)R1(B,50)R2(B,50)W2(B,80)C1C2resultoftransaction(schedule10.1.2)T1:A+B=70T2:A=20,B=80(failsthecreditcheck)2022/12/23UpdateTransaction18Example10.1.1(cont.)2022/12/23UpdateTransaction1910.1TransactionalHistoriesExample10.1.1(cont.)Butthiscouldneverhavehappenedinaserialschedule,wherealloperationofT1occurredbeforeorafteralloperationsofT2.(following)R1(A,50)R1(B,50)C1
R2(A,50)W2(A,20)
R2(B,50)W2(B,80)C2R2(A,50)W2(A,20)
R2(B,50)W2(B,80)C2
R1(A,20)R1(B,80)C1
or2022/12/23UpdateTransaction20ACID(1)AtomicThesetofupdatescontainedinatransactionmustsucceedorfailasaunit.ConsistentCompletetransactionaltransformationsondataelementsbringthedatabasefromoneconsistentstatetoanother.2022/12/23UpdateTransaction21ACID(2)IsolatedEventhoughtransactionsexecuteconcurrently,itappearstoeachsuccessfultransactionthatithasexecutedinaserialschedulewiththeothers.DurableOnceatransactioncommits,thechangesithasmadetothedatawillsurviveanymachineorsystemfailures.2022/12/23UpdateTransaction2210.2InterleavedRead/WriteOperationsIfaserialhistoryisalwaysconsistent,whydon'twejustenforceserialhistories?Figure10.3TxhasrelativelysmallCPUburstsandthenI/OduringwhichCPUhasnothingtodo.Whatdowewanttodo?Figure10.4:LetanotherTyrunduringslackCPUtime.2022/12/23UpdateTransaction2310.2InterleavedRead/WriteOperationsFigure10.5~6Ifwehavemanydisksinuse,wecankeeptheCPU100%occupied.WhenonethreaddoesanI/O,wanttofindanotherthreadwithcompletedI/Oreadytorunagain.2022/12/23UpdateTransaction2410.3SerializabilityandthePrecedenceGraphSerializabilitySchedule(可串行化調(diào)度)TheseriesofoperationsisEQUIVALENTtoaSerialscheduleScheduler(調(diào)度器)findasetofrulesfortheSchedulertoallowoperationsbyinterleavedtransactionsandguaranteeSerializability.Howcanweguaranteethis?2022/12/23UpdateTransaction2510.3SerializabilityandthePrecedenceGraphFirstIftwotransactionsneveraccessthesamedataitems,soWecancommuteoperationsinthehistoryofrequestspermittedbythescheduleruntilalloperationsofoneTxaretogether(serialhistory).Theoperationsdon'taffecteachother,andorderdoesn'tmatter.2022/12/23UpdateTransaction26Ifwehaveoperationsbytwodifferenttransactionsthatdoaffectthesamedataitem,whatthen?Thereareonlyfourpossibilities...R1(A)R2(A)...Thiscanbecommuted.IfthereisathirdtransactionT3,where:...R1(A)...W3(A)...R2(A)...thenthereads(R1andR2)cannotbecommuted....R1(A)W2(A)......W1(A)R2(A)......W1(A)W2(A)...Thesetwooperationscannotcommute.2022/12/23UpdateTransaction2710.3SerializabilityandthePrecedenceGraphDef.10.3.1ConflictingOperations(沖突動作)TwooperationsXi(A)andYj(B)inahistoryaresaidtoconflict
(i.e.,theordermatters)ifandonlyifthefollowingthreeconditionshold:A
BijOneofthetwooperationsXorYisawrite(W).OthercanbeRorW.2022/12/23UpdateTransaction28Def.10.3.1ConflictingOperations(沖突動作)TwooperationsXi(A)andYj(B)inahistoryA
BOperationsondistinctdataitemsneverconflict.ijOperationsconflictonlyiftheyareperformedbydifferenttransactions.TwooperationsoftheSAMEtransactionalsocannotbecommutedinahistory,why
?OneofthetwooperationsXorYisawrite(W).OthercanbeRorW.2022/12/23UpdateTransaction2910.3SerializabilityandthePrecedenceGraphFigure10.7TheThreeTypesRi(A)Wj(A)meaning,inahistory,Ri(A)followedbyWj(A)Wi(A)Rj(A)Wi(A)Wj(A)2022/12/23UpdateTransaction3010.3SerializabilityandthePrecedenceGraphDef.10.3.2AninterpretationofanarbitraryhistoryHconsistsof3parts.Adescriptionofthepurposeofthelogicbeingperformed.Specificationofprecisevaluesfordataitemsbeingreadandwritteninthehistory.Aconsistencyrule,apropertythatisobviouslypreservedbyisolatedtransactionsofthelogicdefinedin1).2022/12/23UpdateTransaction3110.3SerializabilityandthePrecedenceGraphExample10.3.1R2(A)W2(A)R1(A)R1(B)R2(B)W2(B)C1C2H1:HereisaninterpretationT1isdoingacreditcheck,addingupthebalancesofAandB.T2istransferringmoneyfromAtoB.TheConsistencyRule:Neithertransactioncreatesordestroysmoney.2022/12/23UpdateTransaction32ThescheduleH1isnotserializability(SR)becauseIfscheduleH1isequivalenttoserializabilityscheduleS(H1),thenW2(A)&R1(A)isconflictingoperations,and W2(A)<<H1R1(A),soW2(A)<<S(H1)R1(A)ItmeansthatT2<<S(H1)T1R1(B)&W2(B)isconflictingoperations,and R1(B)<<H1W2(B),soR1(B)<<S(H1)W2(B)ItmeansthatT1<<S(H1)T2so,scheduleH1isnotserializability.(non-SR)Example10.3.1R2(A)W2(A)R1(A)R1(B)R2(B)W2(B)C1C2H1:2022/12/23UpdateTransaction3310.3SerializabilityandthePrecedenceGraphExample10.3.2lostupdate(dirtywrite)H2:R1(A)R2(A)W1(A)W2(A)C1C2operations1and4implythatT1<<S(H2)T2operations2and3implythatT2<<S(H2)T1so,H2isnon-SRscheduleH2T1&T2T2&T1valueofA150190190anexampleofH2R1(A,100)R2(A,100)W1(A,140)W2(A,150)C1C22022/12/23UpdateTransaction3410.3SerializabilityandthePrecedenceGraphExample10.3.3BlindWritesH3:W1(A)W2(A)W2(B)W1(B)C1C2operations1and2implythatT1<<S(H3)T2operations3and4implythatT2<<S(H3)T1so,H3isnon-SRscheduleH3T1&T2T2&T1valueofA808050valueofB502050anexampleofH3W1(A,50)W2(A,80)W2(B,20)W1(B,50)C1C22022/12/23UpdateTransaction3510.3SerializabilityandthePrecedenceGraphDef.10.3.3.ThePrecedenceGraphAprecedencegraphforahistoryHisadirectedgraphdenotedbyPG(H).TheverticesofPG(H)correspondtothetransactionsthathaveCOMMITTEDinHmittedtransactionsdon'tcount.AnedgeTiTjexistsinPG(H)whenevertwoconflictingoperationsXiandYjoccurinthatorderinH.Thus,TiTjshouldbeinterpretedtomeanthatTimustprecedeTjinanyequivalentserialhistoryS(H).2022/12/23UpdateTransaction36Theorem10.3.4TheSerializabilityTheoremAhistoryHhasanequivalentserialexecutionS(H)ifftheprecedencegraphPG(H)containsnocircuit.Proof.Assumetherearemtransactionsinvolved,andlabelthemT1,T2,...,Tm.BecauseInanydirectedgraphwithnocircuitthereisalwaysavertexwithnoedgeenteringit,thusthereisavertex,ortransactionTk,withnoedgeenteringit.WechooseTktobeTi(1).2022/12/23UpdateTransaction37Proof.(cont.)NotethatsinceTi(1)hasnoedgeenteringit,thereisnoconflictinHthatforcessomeothertransactiontocomeearlier.Nowremovethisvertex,Ti(1),fromPG(H)andalledgesleavingit.CalltheresultinggraphPG1(H)withnocircuit.Continueinthisfashion,removingTi(2)andallit'sedgesfromPG1(H),andsoon,choosingTi(3)fromPG2(H),...,Ti(m)fromPGm-1(H).2022/12/23UpdateTransaction3810.4LockingEnsuresSerializabilityTwo-PhaseLocking(2PL)封鎖(lock)封鎖類型常用的兩種類型封鎖鎖相容矩陣2022/12/23UpdateTransaction393910.4LockingEnsuresSerializability封鎖(lock)使用封鎖技術(shù)的前提在一個事務(wù)訪問數(shù)據(jù)庫中的數(shù)據(jù)時,必須先獲得被訪問的數(shù)據(jù)對象上的封鎖,以保證數(shù)據(jù)訪問操作的正確性和一致性。封鎖的作用在一段時間內(nèi)禁止其它事務(wù)在被封鎖的數(shù)據(jù)對象上執(zhí)行某些類型的操作(由封鎖的類型決定)同時也表明:持有該封鎖的事務(wù)在被封鎖的數(shù)據(jù)對象上將要執(zhí)行什么類型的操作(由系統(tǒng)所采用的封鎖協(xié)議來決定)2022/12/23UpdateTransaction4010.4LockingEnsuresSerializability封鎖類型常用的封鎖類型有兩種排它鎖(eXclusivelock,簡稱X鎖)又被稱為‘寫封鎖’
(WL–WriteLock)共享鎖(Sharinglock,簡稱S鎖)又被稱為‘讀封鎖’
(RL–ReadLock)2022/12/23UpdateTransaction41排它鎖(X鎖)特性只有當(dāng)數(shù)據(jù)對象A沒有被其它事務(wù)封鎖時,事務(wù)T才能在數(shù)據(jù)對象A上施加‘X鎖’;如果事務(wù)T對數(shù)據(jù)對象A施加了’X鎖’,則其它任何事務(wù)都不能在數(shù)據(jù)對象A上再施加任何類型的封鎖。10.4LockingEnsuresSerializability2022/12/23UpdateTransaction42排它鎖(cont.)作用如果一個事務(wù)T申請在數(shù)據(jù)對象A上施加‘X鎖’并得到滿足,則:事務(wù)T自身可以對數(shù)據(jù)對象A作讀、寫操作,而其它事務(wù)則被禁止訪問數(shù)據(jù)對象A這樣可以讓事務(wù)T獨(dú)占該數(shù)據(jù)對象A,從而保證了事務(wù)T對數(shù)據(jù)對象A的訪問操作的正確性和一致性。缺點(diǎn):降低了整個系統(tǒng)的并行性10.4LockingEnsuresSerializability‘X鎖’必須維持到事務(wù)T的執(zhí)行結(jié)束2022/12/23UpdateTransaction43共享鎖(S鎖)特性如果數(shù)據(jù)對象A沒有被其它事務(wù)封鎖,或者其它事務(wù)僅僅以‘S鎖’的方式來封鎖數(shù)據(jù)對象A時,事務(wù)T才能在數(shù)據(jù)對象A上施加‘S鎖’;10.4LockingEnsuresSerializability2022/12/23UpdateTransaction44共享鎖(cont.)作用如果一個事務(wù)T申請在數(shù)據(jù)對象A上施加‘S鎖’并得到滿足,則:事務(wù)T可以對‘讀’數(shù)據(jù)對象A,但不能‘寫’數(shù)據(jù)對象A不同事務(wù)所申請的‘S鎖’可以共存于同一個數(shù)據(jù)對象A上,從而保證了多個事務(wù)可以同時‘讀’數(shù)據(jù)對象A,有利于提高整個系統(tǒng)的并發(fā)性在持有封鎖的事務(wù)釋放數(shù)據(jù)對象A上的所有‘S鎖’之前,任何事務(wù)都不能‘寫’數(shù)據(jù)對象A‘S鎖’不必維持到事務(wù)T的執(zhí)行結(jié)束(依封鎖協(xié)議而定)10.4LockingEnsuresSerializability2022/12/23UpdateTransaction45‘排它鎖’與‘共享鎖’的相互關(guān)系可以用如下圖所示的‘鎖相容矩陣’來表示。當(dāng)前事務(wù)申請的鎖其它事務(wù)已持有的鎖YesYesNoS鎖YesNoNoX鎖-S鎖X鎖鎖相容矩陣10.4LockingEnsuresSerializability2022/12/23UpdateTransaction46合適(wellformed)事務(wù)如果一個事務(wù)在訪問數(shù)據(jù)庫中的數(shù)據(jù)對象A之前按照要求申請對A的封鎖,在操作結(jié)束后釋放A上的封鎖,這種事務(wù)被稱為合適事務(wù)?!线m事務(wù)’是保證并發(fā)事務(wù)的正確執(zhí)行的基本條件。10.4LockingEnsuresSerializability2022/12/23UpdateTransaction4710.4LockingEnsuresSerializabilityDef.10.4.1Two-PhaseLocking(2PL)Lockstakeninreleasedfollowingthreerules.鎖申請規(guī)則鎖申請的等待規(guī)則單個事務(wù)的鎖申請與釋放規(guī)則2022/12/23UpdateTransaction4810.4LockingEnsuresSerializabilityDef.10.4.1Two-PhaseLocking(cont.)BeforeTicanreadadataitem,Ri(A),schedulerattemptstoReadLocktheitemonit'sbehalf,RLi(A);before
Wi(A),tryWriteLock,WLi(A).2022/12/23UpdateTransaction4910.4LockingEnsuresSerializabilityDef.10.4.1Two-PhaseLocking(cont.)2)Ifconflictinglockonitemexists,requestingTx
mustWAIT.Conflictinglockscorrespondingtoconflictingoperations:twolocksonadataitemconflictiftheyareattemptedbydifferentTxsandatleastoneofthemisaWL.2022/12/23UpdateTransaction5010.4LockingEnsuresSerializabilityTherearetwophasestolockingthegrowingphasetheshrinkingphasewhenlocksarereleased:RUi(A);Theschedulermustensurethatcan'tshrink(dropalock)andthengrowagain(takeanewlock).Rule3)impliescanreleaselocksbeforeCommit;MoreusualtoreleasealllocksatonceonCommit,andweshallassumethisinwhatfollows.2022/12/23UpdateTransaction5110.4LockingEnsuresSerializabilityNotethatatransactioncanneverconflictwithitsownlocks!IfTi
holdsRLonA,cangetWLonAsolongasnootherTx
holdsalockonA(mustbeRL).aTx
withaWLdoesn'tneedaRL(WLmorepowerfulthanRL).2022/12/23UpdateTransaction5210.4LockingEnsuresSerializabilityClearlylockingisdefinedtoguaranteethatacircuitinthePrecedenceGraphcanneveroccur.ThefirstTx
tolockanitemforcesanyotherTxthatgetstoitsecondto"comelater"inanySG.ButwhatifotherTxalreadyholdsalockthefirstonenowneeds?Thiswouldmeanacircuit,butintheWAITrulesoflockingitmeansNEITHERTx
CANEVERGOFORWARDAGAIN.ThisisaDEADLOCK.2022/12/23UpdateTransaction53Example10.4.1ScheduleExplanationABRL1(A)50501R1(A,50)5050RL2(A)50502R2(A,50)5050WL2(A)T2WAIT5050RL1(B)50506R1(B,50)50507C1T2cangetWL2(A)50503W2(A,20)2050RL2(B)20504R2(B,50)2050WL2(B)20505W2(B,80)20808C22080H41R1(A)2R2(A)3W2(A)4R2(B)5W2(B)6R1(B)7C18C2non-SRSerializability2022/12/23UpdateTransaction54Example10.4.2ScheduleABT1T2RL1(A)50501R1(A,50)5050RL2(B)50502R2(B,50)5050WL2(B)50503W2(B,80)5080RL2(A)50804R2(A,50)5080WL2(A)5080T2waitingRL1(B)T1waitingH51R1(A)2R2(B)3W2(B)4R2(A)5W2(A)6R1(B)7C18C2non-SRDeadlock2022/12/23UpdateTransaction5510.4LockingEnsuresSerializabilityTheorem.10.4.2LockingTheoremAhistoryoftransactionaloperationsthatfollowsthe2PLdisciplineisSR(Serializability).short-termlocksAlockistakenpriortotheoperation(RorW)andreleasedIMMEDIATELYAFTERWARD.long-termlocksAlockarehelduntilEOT(EndOfTransaction).2022/12/23UpdateTransaction5610.5LevelsofIsolation定義當(dāng)前用戶的事務(wù)與其它并發(fā)執(zhí)行事務(wù)之間的隔離級別(levelofisolation)事務(wù)的隔離級別與所采用的封鎖策略緊密相關(guān)SETTRANSACTIONISOLATIONLEVELMITTED|MITTED|READREPEATABLE|SERIALIZABLE2022/12/23UpdateTransaction5710.5LevelsofIsolationMITTED:未提交讀在該方式下,當(dāng)前事務(wù)不需要申請任何類型的封鎖,因而可能會‘讀’到未提交的修改結(jié)果禁止一個事務(wù)以該方式去執(zhí)行對數(shù)據(jù)的‘寫’操作,以避免‘寫’沖突現(xiàn)象。MITTED:提交讀在‘讀’數(shù)據(jù)對象A之前需要先申請對數(shù)據(jù)對象A的‘共享性’封鎖,在‘讀’操作執(zhí)行結(jié)束之后立即釋放該封鎖。以避免讀取未提交的修改結(jié)果。2022/12/23UpdateTransaction5810.5LevelsofIsolationREADREPEATABLE:可重復(fù)讀在‘讀’數(shù)據(jù)對象A之前需要先申請對數(shù)據(jù)對象A的‘共享性’封鎖,并將該封鎖維持到當(dāng)前事務(wù)的結(jié)束??梢员苊馄渌牟l(fā)事務(wù)對當(dāng)前事務(wù)正在使用的數(shù)據(jù)對象的修改。SERIALIZABLE:可序列化(可串行化)并發(fā)事務(wù)以一種可串行化的調(diào)度策略實(shí)現(xiàn)其并發(fā)執(zhí)行,以避免它們相互之間的干擾現(xiàn)象。2022/12/23UpdateTransaction5910.5LevelsofIsolation不管采用何種隔離級別,在事務(wù)‘寫’數(shù)據(jù)對象A之前需要先申請對數(shù)據(jù)對象A的‘排它性’封鎖(write-lock),并將該封鎖維持到當(dāng)前事務(wù)的結(jié)束。2022/12/23UpdateTransaction6010.5LevelsofIsolationlong-termshort-termshort-termNoReadLocks(Predicates)Nolong-termYesSerializableUpdateAnomalylong-termYesRepeatableReadLostUpdateshort-termYesReadCommittedDirtyReadsNoNo(ReadOnly)ReadmittedProblemReadLocks(row)WritelocksLevelsofIsolationTypesofLocks2022/12/23UpdateTransaction6110.6TransactionalRecoveryLogsThelogentriescontain"BeforeImages"and"AfterImages"ofeveryupdatemadebyaTransaction.BeforeImageAfterImage2022/12/23UpdateTransaction6210.6TransactionalRecoveryBeforeImageInrecovery,wecanbackupanupdatethatshouldn'thavegottentodisk(thetransactiondidn'tcommit)byapplyingaBeforeImage.AfterImageInrecovery,wecanapplyAfterImagestocorrectfordiskpagesthatshouldhavegottentodisk(thetransactiondidcommit)butnevermadeit.2022/12/23UpdateTransaction6310.6TransactionalRecoveryThreetypesofLogsUNDOLogsonlyBeforeImageRecoveryforthetransactiondidn’tcommit.REDOLogsonlyAfterImageRecoveryforthetransactiondidcommit.UNDO/REDOLogsBeforeImage&AfterImageRecoveryforalltransactions.2022/12/23UpdateTransaction6410.7RecoveryinDetail:LogFormatsFigure10.13(pg.673)OperationLogentryExplanationR1(A,50)(S,1)StarttransactionT1-nologentryiswrittenforaReadoperation.W1(A,20)(W,1,A,50,20)T1WritelogforupdateofA.balance.Thevalue50istheBeforeImage(BI)forA.balancecolumninrowA,20istheAfterImage(AI)forA.balanceR2(C,100)(S,2)Anotherstarttransactionlogentry.W2(C,50)(W,2,C,100,50)AnotherWritelogentry.C2(C,2)CommitT2logentry.(WriteLogBuffertoLogFile)R1(B,50)NologentryW1(B,80)(W,1,B,50,80)C1(C,1)CommitT1(WriteLogBuffertoLogFile)2022/12/23UpdateTransaction6510.7RecoveryinDetail:LogFormatsAssumethataSystemCrashoccurredimmediatelyaftertheW1(B,80)operation.2022/12/23UpdateTransaction66Logentry5(S,1)4(W,1,A,50,20)3(S,2)2(W,2,C,100,50)1(C,2)FailureROLLBACKACTIONPERFORMEDMakeanotethatT1isnolonger"Active".Nowthatnotransactionswereactive,wecanendtheROLLBACKphase.TransactionT1hasnevercommitted(it'slastoperationwasaWrite).Therefore,thesystemperformsUNDOofthisupdatebyWritingtheBeforeImagevalue(50)intodataitemA.PutT1into"mittedList“.MakeanotethatT2isnolonger"Active"SinceT2ison"CommittedList",wedonothing.PutT2into"CommittedList"2022/12/23UpdateTransaction67LogentryROLLFORWARDACTIONPERFORMED6(S,1)Noactionrequired.7(W,1,A,50,20)T1ismitted—Noactionrequired.8(S,2)Noactionrequired.9(W,2,C,100,50)SinceT2isonCommittedList,weREDOthisupdatebywritingAfterImagevalue(50)intodataitemC.10(C,2)Noactionrequired.11Wenotethatwehaverolledforwar
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 共青科技職業(yè)學(xué)院《高級商務(wù)英語(一)》2023-2024學(xué)年第一學(xué)期期末試卷
- 《知識經(jīng)濟(jì)時代》課件
- 2022年一級建造師-管理-李娜章節(jié)練習(xí)題講義合集(含答案解析)
- 贛南科技學(xué)院《大數(shù)據(jù)技術(shù)基礎(chǔ)(計算模型)》2023-2024學(xué)年第一學(xué)期期末試卷
- 贛東學(xué)院《翻譯概論》2023-2024學(xué)年第一學(xué)期期末試卷
- 甘肅中醫(yī)藥大學(xué)《土木工程結(jié)構(gòu)試驗(yàn)與檢測》2023-2024學(xué)年第一學(xué)期期末試卷
- 語文培訓(xùn)機(jī)構(gòu)課件
- 七年級科學(xué)上冊第1章科學(xué)入門第3節(jié)科學(xué)觀察第1課時教案新版浙教版
- 七年級道德與法治上冊第四單元生命的思考第十課綻放生命之花第1課時感受生命的意義教案新人教版
- 三年級數(shù)學(xué)上冊五周長什么是周長說課稿北師大版
- 2024年度員工試用期勞動合同模板(含保密條款)3篇
- 2024-2030年全球與中國汽車音頻DSP芯片組市場銷售前景及競爭策略分析報告
- 機(jī)關(guān)事業(yè)單位財務(wù)管理制度(六篇)
- 2025禮品定制合同范本
- 醫(yī)院消毒隔離制度范文(2篇)
- 2024年01月11026經(jīng)濟(jì)學(xué)(本)期末試題答案
- 烘干煤泥合同范例
- 人教版六年級上冊數(shù)學(xué)第八單元數(shù)學(xué)廣角數(shù)與形單元試題含答案
- 2025年“三基”培訓(xùn)計劃
- 第20課 北洋軍閥統(tǒng)治時期的政治、經(jīng)濟(jì)與文化 教案
- 叉車租賃合同模板
評論
0/150
提交評論