版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quá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獨占該數(shù)據(jù)對象A,從而保證了事務(wù)T對數(shù)據(jù)對象A的訪問操作的正確性和一致性。缺點:降低了整個系統(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é)束。可以避免其它的并發(fā)事務(wù)對當(dāng)前事務(wù)正在使用的數(shù)據(jù)對象的修改。SERIALIZABLE:可序列化(可串行化)并發(fā)事務(wù)以一種可串行化的調(diào)度策略實現(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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024秋八年級英語上冊 Unit 10 If you go to the party you'll have a great time Section B (2a-2e)教案(新版)人教新目標(biāo)版
- 2023七年級歷史下冊 第二單元 遼宋夏金元時期:民族關(guān)系發(fā)展和社會變化第8課 金與南宋的對峙說課稿 新人教版
- 喜達屋酒店內(nèi)部員工管理制度
- 高考地理一輪復(fù)習(xí)第一章地球與地圖第一節(jié)經(jīng)緯網(wǎng)和地圖課件
- 自營業(yè)務(wù)外包合同(2篇)
- 腦卒中相關(guān)課件
- 布紋個性簡歷幻燈片模板
- 西京學(xué)院《應(yīng)用統(tǒng)計學(xué)》2022-2023學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《家具設(shè)計》2023-2024學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《發(fā)電廠電氣系統(tǒng)》2022-2023學(xué)年期末試卷
- 責(zé)任心的力量PPT模板:共建美好世界
- 監(jiān)控施工方案四篇
- 某標(biāo)準(zhǔn)件廠冷鐓車間低壓配電系統(tǒng)及車間變電所設(shè)計(超詳細)
- 紫金礦業(yè)污染事件商業(yè)倫理分析
- 體檢指標(biāo)分析課件
- 2023年口腔醫(yī)學(xué)期末復(fù)習(xí)-牙周病學(xué)(口腔醫(yī)學(xué))考試歷年真題精華集選附答案
- 中小學(xué)教師教育教學(xué)水平能力測試成績單
- 骨科細化分級護理標(biāo)準(zhǔn)
- 互聯(lián)網(wǎng)醫(yī)院整體方案介紹-PPT
- 4.2.1指數(shù)函數(shù)的概念 課件(共21張PPT)
- 嬰幼兒盥洗照料(嬰幼兒回應(yīng)性照護課件)
評論
0/150
提交評論