关系论坛头像图片
论坛头像图片 时间:2021-04-13 阅读:(
)
当前无法显示此图像.
Lecture13RecoverySystemQiwenDongJun20,2011SchoolofComputerScienceFudanUniversity2012-06-13SchoolofC.
S.
,FudanUniv.
2OutlineTransactionfailureLogicalerrorsSystemerrorsSystemcrashApowerfailureorotherhardwareorsoftwarefailurecausesthesystemtocrashDiskfailureAheadcrashorsimilardiskfailuredestroysallorpartofdiskstorage2012-06-13SchoolofC.
S.
,FudanUniv.
3RecoveryAlgorithmsTechniquestoensuredatabaseconsistencyandtransactionatomicityanddurabilitydespitefailuresRecoveryalgorithmshavetwoparts1.
Actionstakenduringnormaltransactionprocessing2.
Actionstakenafterafailure当前无法显示此图像.
DataAccess2012-06-13SchoolofC.
S.
,FudanUniv.
5StorageStructureVolatilestoragedoesnotsurvivesystemcrashesexamples:mainmemory,cachememoryNonvolatilestoragesurvivessystemcrashesexamples:disk,tape,flashmemoryStablestorageamythicalformofstoragethatsurvivesallfailuresapproximatedbymaintainingmultiplecopiesondistinctnonvolatilemedia2012-06-13SchoolofC.
S.
,FudanUniv.
6DataAccessPhysicalblocksarethoseblocksresidingonthedisk.
Bufferblocksaretheblocksresidingtemporarilyinmainmemory.
Blockmovementsbetweendiskandmainmemoryare:input(B)output(B)EachtransactionTihasitsprivatework-areaTi'slocalcopyofadataitemXiscalledxi.
Weassume,forsimplicity,thateachdataitemfitsin,andisstoredinside,asingleblock.
2012-06-13SchoolofC.
S.
,FudanUniv.
7DataAccess(Cont.
)Transactiontransfersdataitemsbetweensystembufferblocksanditsprivatework-areausingread(X)write(X)TransactionsPerformread(X)whileaccessingXforthefirsttimeAllsubsequentaccessesaretothelocalcopyAfterlastaccess,transactionexecuteswrite(X)output(BX)neednotimmediatelyfollowwrite(X)Systemcanperformtheoutputoperationwhenitdeemsfit2012-06-13SchoolofC.
S.
,FudanUniv.
8ExampleofDataAccessxYABx1y1bufferBufferBlockABufferBlockBinput(A)output(B)read(X)write(Y)diskworkareaofT1workareaofT2memoryx22012-06-13SchoolofC.
S.
,FudanUniv.
9Modifyingthedatabase(withoutensuringthatthetransactionwillcommit)mayleavethedatabaseinaninconsistentstate.
ConsidertransactionTithattransfers$50fromaccountAtoaccountB;goaliseithertoperformalldatabasemodificationsmadebyTiornoneatall.
SeveraloutputoperationsmayberequiredforTi(tooutputAandB).
Afailuremayoccurafteroneofthesemodificationshavebeenmadebutbeforeallofthemaremade.
RecoveryandAtomicity2012-06-13SchoolofC.
S.
,FudanUniv.
10RecoveryandAtomicity(Cont.
)Toensureatomicitydespitefailures,wefirstoutputinformationdescribingthemodificationstostablestoragewithoutmodifyingthedatabaseitself.
Therearetwoapproaches:log-basedrecovery(基于日志的恢复)shadow-paging(影子页)Weassume(initially)thattransactionsrunserially,thatis,oneaftertheother当前无法显示此图像.
Log-basedRecovery2012-06-13SchoolofC.
S.
,FudanUniv.
12Log-BasedRecoveryAlogiskeptonstablestorage.
Thelogisasequenceoflogrecords.
Weassumethatlogrecordsarenotbuffered.
WhentransactionTistarts,itregistersitselfbywritingalogrecordBeforeTiexecuteswrite(X),alogrecordiswrittenWhenTifinishesit'slaststatement,thelogrecordiswritten.
TwoapproachesusinglogsDeferreddatabasemodification(延迟数据库修改)Immediatedatabasemodification(即刻数据库修改)2012-06-13SchoolofC.
S.
,FudanUniv.
13DeferredDatabaseModificationRecordsallmodificationstothelog,butdefersallthewritestoafterpartialcommit.
Transactionstartsbywritingrecordtolog.
Awrite(X)operationresultsinalogrecordbeingwritten.
ThewriteisnotperformedonXatthistime,butisdeferred.
WhenTipartiallycommits,iswrittentothelogFinally,thelogrecordsarereadandusedtoactuallyexecutethepreviouslydeferredwrites.
2012-06-13SchoolofC.
S.
,FudanUniv.
14Duringrecoveryafteracrashatransactionneedstoberedoneiffbothandarethereinthelog.
Redo(Ti)setsthevalueofalldataitemsupdatedbythetransactiontothenewvalues.
example(T0executesbeforeT1):T0:read(A)T1:read(C)A:-A-50C:-C-100Write(A)write(C)read(B)B:-B+50write(B)DeferredDatabaseModification(Cont.
)2012-06-13SchoolofC.
S.
,FudanUniv.
15Iflogonstablestorageattimeofcrashisasincase:(a)Noredoactionsneedtobetaken(b)redo(T0)mustbeperformed(c)redo(T0)mustbeperformedfollowedbyredo(T1)DeferredDatabaseModification(Cont.
)2012-06-13SchoolofC.
S.
,FudanUniv.
16ImmediateDatabaseModificationAllowsdatabaseupdatesofanuncommittedtransactiontobemadeasthewritesareissuedUpdatelogrecordmustbewrittenbeforedatabaseitemiswrittenOutputofupdatedblockscantakeplaceatanytimebeforeoraftertransactioncommitOrderinwhichblocksareoutputcanbedifferentfromtheorderinwhichtheyarewritten.
2012-06-13SchoolofC.
S.
,FudanUniv.
17LogWriteOutputA=950B=2050C=600BB,BCBANote:BXdenotesblockcontainingXx1ImmediateDatabaseModificationExample2012-06-13SchoolofC.
S.
,FudanUniv.
18Recoveryprocedurehastwooperations:undo(Ti)redo(Ti)Bothoperationsmustbeidempotent(等幂/幂等的)Thatis,eveniftheoperationisexecutedmultipletimestheeffectisthesameasifitisexecutedonceWhenrecoveringafterfailure:TransactionTineedstobeundoneifthelogcontainstherecord,butdoesnotcontain.
TransactionTineedstoberedoneifthelogcontainsboththerecordand.
Undooperationsareperformedfirst,thenredooperations.
ImmediateDatabaseModification(Cont.
)2012-06-13SchoolofC.
S.
,FudanUniv.
19Recoveryactionsineachcaseaboveare:(a)undo(T0)(b)undo(T1)andredo(T0)(c)redo(T0)andredo(T1)ImmediateDBModificationRecoveryExample当前无法显示此图像.
Checkpoints2012-06-13SchoolofC.
S.
,FudanUniv.
21Checkpoints(检查点)Problemsintherecoveryprocedure:1.
searchingtheentirelogistime-consuming2.
wemightunnecessarilyredotransactionswhichhavealreadyoutputtheirupdatestothedatabase.
Recoveryprocedurebyperiodicallyperformingcheckpointing1.
Outputalllogrecordscurrentlyresidinginmainmemoryontostablestorage.
2.
Outputallmodifiedbufferblockstothedisk.
3.
Writealogrecordontostablestorage.
2012-06-13SchoolofC.
S.
,FudanUniv.
22Checkpoints(Cont.
)Duringrecovery:1.
Scanbackwardsfromendoflogtofindthemostrecentrecord2.
Continuescanningbackwardstillarecordisfound(Wehaveassumethatalltransactionsareexecutedserially)3.
Needonlyconsiderthepartoflogfollowingabovestartrecord.
4.
Foralltransactions(startingfromTiorlater)withno,executeundo(Ti).
5.
Scanningforwardinthelog,foralltransactionsstartingfromTiorlaterwitha,executeredo(Ti).
2012-06-13SchoolofC.
S.
,FudanUniv.
23ExampleofCheckpointsT1canbeignored(updatesalreadyoutputtodiskduetocheckpoint)T2andT3redone.
T4undoneTcTfT1T2T3T4checkpointsystemfailure当前无法显示此图像.
ConcurrentTransactions2012-06-13SchoolofC.
S.
,FudanUniv.
25Wemodifythelog-basedrecoveryschemestoallowmultipletransactionstoexecuteconcurrently.
AlltransactionsshareasinglediskbufferandasinglelogAbufferblockcanhavedataitemsupdatedbyoneormoretransactionsWeassumeconcurrencycontrolusingstricttwo-phaselocking;Loggingisdoneasdescribedearlier.
Logrecordsofdifferenttransactionsmaybeinterspersedinthelog.
ThecheckpointingtechniqueandactionstakenonrecoveryhavetobechangedRecoveryWithConcurrentTransactions2012-06-13SchoolofC.
S.
,FudanUniv.
26Checkpointsareperformedasbefore,exceptthatthecheckpointlogrecordistheformLisalistoftransactionsactiveatthetimeofthecheckpointWeassumenoupdateisinprogresswhilethecheckpointiscarriedout(thiscanberelaxed)Whenthesystemrecoversfromacrash:1.
Initializeundo-listandredo-listtoempty2.
Scanthelogbackwardsuntilarecordisfound:iftherecordis,addTitoredo-listiftherecordis,thenifTiisnotinredo-list,addTitoundo-list3.
ForeveryTiinL,ifTiisnotinredo-list,addTitoundo-listRecoveryWithConcurrentTransactions(Cont.
)2012-06-13SchoolofC.
S.
,FudanUniv.
27Recoverynowcontinuesasfollows:1.
ScanlogbackwardsfromtheendofthelogDuringthescan,performundoforeachlogrecordthatbelongstoatransactioninundo-list.
2.
Locatethemostrecentrecord.
3.
Scanlogforwardsfromtherecordtilltheendofthelog.
Duringthescan,performredoforeachlogrecordthatbelongstoatransactiononredo-listRecoveryWithConcurrentTransactions(Cont.
)2012-06-13SchoolofC.
S.
,FudanUniv.
28ExampleofRecoveryGooverthestepsoftherecoveryalgorithmonthefollowinglog:2012-06-13SchoolofC.
S.
,FudanUniv.
29LogRecordBufferingLogrecordbuffering:logrecordsarebufferedinmainmemory,insteadofofbeingoutputdirectlytostablestorage.
Logrecordsareoutputtostablestoragewhenablockoflogrecordsinthebufferisfull,oralogforceoperationisexecuted.
Logforceisperformedtocommitatransactionbyforcingallitslogrecords(includingthecommitrecord)tostablestorage.
Severallogrecordscanthusbeoutputusingasingleoutputoperation,reducingtheI/Ocost.
2012-06-13SchoolofC.
S.
,FudanUniv.
30LogRecordBuffering(Cont.
)Therulesbelowmustbefollowediflogrecordsarebuffered:Logrecordsareoutputtostablestorageintheorderinwhichtheyarecreated.
TransactionTientersthecommitstateonlywhenthelogrecordhasbeenoutputtostablestorage.
Beforeablockofdatainmainmemoryisoutputtothedatabase,alllogrecordspertainingtodatainthatblockmusthavebeenoutputtostablestorage.
Thisruleiscalledthewrite-aheadloggingorWALrule2012-06-13SchoolofC.
S.
,FudanUniv.
31DatabaseBufferingDatabasemaintainsanin-memorybufferofdatablocksWhenanewblockisneeded,ifbufferisfullanexistingblockneedstoberemovedfrombufferIftheblockchosenforremovalhasbeenupdated,itmustbeoutputtodiskNoupdateshouldbeinprogressonablockwhenitisoutputtodisk.
Canbeensuredasfollows.
Beforewritingadataitem,transactionacquiresexclusivelockonblockcontainingthedataitemLockcanbereleasedoncethewriteiscompleted.
Suchlocksheldforshortdurationarecalledlatches.
Beforeablockisoutputtodisk,thesystemacquiresanexclusivelatchontheblockEnsuresnoupdatecanbeinprogressontheblock2012-06-13SchoolofC.
S.
,FudanUniv.
32BufferManagement(Cont.
)Databasebuffercanbeimplementedeitherinanareaofrealmain-memoryreservedforthedatabase,orinvirtualmemoryImplementingbufferinreservedmain-memoryhasdrawbacks:Memoryispartitionedbefore-handbetweendatabasebufferandapplications,limitingflexibility.
Needsmaychange,andalthoughoperatingsystemknowsbesthowmemoryshouldbedividedupatanytime,itcannotchangethepartitioningofmemory.
2012-06-13SchoolofC.
S.
,FudanUniv.
33BufferManagement(Cont.
)Databasebuffersaregenerallyimplementedinvirtualmemoryinspiteofsomedrawbacks:WhenOSneedstoevictapagethathasbeenmodified,thepageiswrittentoswapspaceondisk.
WhenDBdecidestowritebufferpagetodisk,bufferpagemaybeinswapspace,andmayhavetobereadfromswapspaceondiskandoutputtothedatabaseondisk,resultinginextraI/O!
Knownasdualpagingproblem.
Ideallywhenswappingoutadatabasebufferpage,operatingsystemshouldpasscontroltodatabase,whichinturnoutputspagetodatabaseinsteadoftoswapspace(makingsuretooutputlogrecordsfirst)Dualpagingcanthusbeavoided,butcommonoperatingsystemsdonotsupportsuchfunctionality.
2012-06-13SchoolofC.
S.
,FudanUniv.
34FailurewithLossofNonvolatileStorageTechniquesimilartocheckpointingusedtodealwithlossofnon-volatilestoragePeriodicallydumptheentirecontentofthedatabasetostablestorageNotransactionmaybeactiveduringthedumpprocedure;aproceduresimilartocheckpointingmusttakeplaceOutputalllogrecordscurrentlyresidinginmainmemoryontostablestorage.
Outputallbufferblocksontothedisk.
Copythecontentsofthedatabasetostablestorage.
Outputarecordtologonstablestorage.
Torecoverfromdiskfailurerestoredatabasefrommostrecentdump.
ConsultthelogandredoalltransactionsthatcommittedafterthedumpCanbeextendedtoallowtransactionstobeactiveduringdump;knownasfuzzydumporonlinedump2012-06-13SchoolofC.
S.
,FudanUniv.
35考试要点(仅列出要点,不是全部考试范围)ER模型:能够设计ER模型,并绘制ER图能够转换成关系模式关系代数能够写出给定关系代数的结果能够针对特定查询写出对应的关系代数表达式能够写出select语句的查询结果关系模式规范化能计算属性集的闭包无损分解和保持依赖分解的判据能够分析关系是否满足某些范式能够分析关系模式的分解性质2012-06-13SchoolofC.
S.
,FudanUniv.
36考试要点(仅列出要点,不是全部考试范围)查询处理:理解各种查询处理算法能够分析并计算各种连接的代价事务处理可串行化的判定并发控制理解两阶段封锁协议和时间戳协议的执行过程死锁产生的原因和处理方法能够根据并发执行的事物,构造等待图,处理死锁树形协议的优缺点数据库恢复能够根据事物的执行写出日志能够在数据库故障时,根据日志进行恢复
DMIT.io是成立于2018年的一家国外主机商,提供VPS主机和独立服务器租用,数据中心包括中国香港、美国洛杉矶和日本等,其中日本VPS是新上的节点,基于KVM架构,国际线路,1Gbps带宽,同时提供月付循环8折优惠码,或者年付一次性5折优惠码,优惠后最低每月8.72美元或者首年65.4美元起,支持使用PayPal或者支付宝等付款方式。下面列出部分日本VPS主机配置信息,价格以月付为例。CPU:...
我们先普及一下常识吧,每年9月的第一个星期一是美国劳工节。于是,有一些服务商会基于这些节日推出吸引用户的促销活动,比如RackNerd有推出四款洛杉矶和犹他州独立服务器,1G带宽、5个独立IP地址,可以配置Windows和Linux系统,如果有需要独立服务器的可以看看。第一、劳工节促销套餐这里有提供2个套餐。两个方案是选择犹他州的,有2个方案是可以选择洛杉矶机房的。CPU内存SSD硬盘配置流量价格...
IMIDC发布了6.18大促销活动,针对香港、台湾、日本和莫斯科独立服务器提供特别优惠价格最低月付30美元起。IMIDC名为彩虹数据(Rainbow Cloud),是一家香港本土运营商,全线产品自营,自有IP网络资源等,提供的产品包括VPS主机、独立服务器、站群独立服务器等,数据中心区域包括香港、日本、台湾、美国和南非等地机房,CN2网络直连到中国大陆。香港服务器 $39/...
论坛头像图片为你推荐
操作httpHive常用函数大全一览支持ipad重庆网络公司一九互联网络公司做一个网站大概需要多少钱中国企业在线中金在线和中金公司有关系吗支付宝调整还款日花呗还款日是什么时候呢netshwinsockreset电脑开机老是出现wwbizsrv.exe 应用程序错误 怎么处理Usercuteftp抢米网什么意思抢小米手机灌水机什么是论坛灌水机?在哪里可以下载到呢?
香港虚拟空间 注册cn域名 ftp空间 阿里云os iis安装教程 php探针 主机合租 最好的免费空间 hinet vip域名 外贸空间 域名转入 美国asp空间 免费网站加速 webmin tko 云主机 次世代主机 国内免备案cdn 大容量存储方案 更多