数据库-研究生课件:第24章 高级事务处理_第1页
数据库-研究生课件:第24章 高级事务处理_第2页
数据库-研究生课件:第24章 高级事务处理_第3页
数据库-研究生课件:第24章 高级事务处理_第4页
数据库-研究生课件:第24章 高级事务处理_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第24章高级事务处理Transaction-ProcessingMonitorsTransactionalWorkflowsHigh-PerformanceTransactionSystemsMainmemorydatabasesReal-TimeTransactionSystemsLong-DurationTransactionsTransactionmanagementinmultidatabasesystems1TransactionProcessingMonitorsTPmonitorsinitiallydevelopedasmultithreadedserverstosupportlargenumbersofterminalsfromasingleprocess.Provideinfrastructureforbuildingandadministeringcomplextransactionprocessingsystemswithalargenumberofclientsandmultipleservers.Provideservicessuchas:PresentationfacilitiestosimplifycreatinguserinterfacesPersistentqueuingofclientrequestsandserverresponsesRoutingofclientmessagestoserversCoordinationoftwo-phasecommitwhentransactionsaccessmultipleservers.SomecommercialTPmonitors:CICSfromIBM,PathwayfromTandem,TopEndfromNCR,andEncinafromTransarc2TPMonitorArchitectures3TPMonitorArchitecturesProcessperclientmodel-insteadofindividualloginsessionperterminal,serverprocesscommunicateswiththeterminal,handlesauthentication,andexecutesactions.MemoryrequirementsarehighMultitasking-highCPUoverheadforcontextswitchingbetweenprocessesSingleprocessmodel-allremoteterminalsconnecttoasingleserverprocess.Usedinclient-serverenvironmentsServerprocessismulti-threaded;lowcostforthreadswitchingNoprotectionbetweenapplicationsNotsuitedforparallelordistributeddatabases4TPMonitorArchitecturesMany-serversingle-routermodel-multipleapplicationserverprocessesaccessacommondatabase;clientscommunicatewiththeapplicationthroughasinglecommunicationprocessthatroutesrequests.IndependentserverprocessesformultipleapplicationsMultithreadserverprocessRunonparallelordistributeddatabaseManyservermany-routermodel-multipleprocessescommunicatewithclients.Clientcommunicationprocessesinteractwithrouterprocessesthatroutetheirrequeststotheappropriateserver.Controllerprocessstartsupandsupervisesotherprocesses.5DetailedStructureofaTPMonitor6DetailedStructureofaTPMonitorQueuemanagerhandlesincomingmessagesSomequeuemanagersprovidepersistentordurablemessagequeueingcontentsofqueuearesafeevenifsystemsfails.Durablequeueingofoutgoingmessagesisimportantapplicationserverwritesmessagetodurablequeueaspartofatransactiononcethetransactioncommits,theTPmonitorguaranteesmessageiseventuallydelevered,regardlessofcrashes.ACIDpropertiesarethusprovidedevenformessagessentoutsidethedatabaseManyTPmonitorsprovidelocking,loggingandrecoveryservices,toenableapplicationserverstoimplementACIDpropertiesbythemselves.7ApplicationCoordinationUsingTPMonitorsATPmonitortreatseachsubsystemasaresourcemanagerthatprovidestransactionalaccesstosomesetofresources.TheinterfacebetweentheTPmonitorandtheresourcemanagerisdefinedbyasetoftransactionprimitivesTheresourcemanagerinterfaceisdefinedbytheX/OpenDistributedTransactionProcessingstandard.TPmonitorsystemsprovideatransactionalremoteprocedurecall(transactionalRPC)interfacetotheirserviceTransactionalRPCprovidescallstoencloseaseriesofRPCcallswithinatransaction.UpdatesperformedbyanRPCarecarriedoutwithinthescopeofthetransaction,andcanberolledbackifthereisanyfailure.8WorkflowSystems9Copyright:Silberschatz,KorthandSudarshanTransactionalWorkflowsWorkflowsareactivitiesthatinvolvethecoordinatedexecutionofmultipletasksperformedbydifferentprocessingentities.Withthegrowthofnetworks,andtheexistenceofmultipleautonomousdatabasesystems,workflowsprovideaconvenientwayofcarryingouttasksthatinvolvemultiplesystems.Exampleofaworkflowdeliveryofanemailmessage,whichgoesthroughseveralmailssystemstoreachdestination.Eachmailerperformsatasks:forwardingofthemailtothenextmailer.Ifamailercannotdelivermail,failuremustbehandledsemantically(deliveryfailuremessage).Workflowsusuallyinvolvehumans:e.g.loanprocessing,orpurchaseorderprocessing.10ExamplesofWorkflows11LoanProcessingWorkflowInthepast,workflowswerehandledbycreatingandforwardingpaperformsComputerizedworkflowsaimtoautomatemanyofthetasks.Butthehumansstillplayrolee.g.inapprovingloans.12TransactionalWorkflowsMustaddressfollowingissuestocomputerizeaworkflow.Specificationofworkflows-detailingthetasksthatmustbecarriedoutanddefiningtheexecutionrequirements.Executionofworkflows-executetransactionsspecifiedintheworkflowwhilealsoprovidingtraditionaldatabasesafeguardsrelatedtothecorrectnessofcomputations,dataintegrity,anddurability.E.g.:Loanapplicationshouldnotgetlostevenifsystemfails.Extendtransactionconceptstothecontextofworkflows.Stateofaworkflow-consistsofthecollectionofstatesofitsconstituenttasks,andthestates(i.e.values)ofallvariablesintheexecutionplan.13WorkflowSpecificationStaticspecificationoftaskcoordination:Tasksanddependenciesamongthemaredefinedbeforetheexecutionoftheworkflowstarts.Canestablishpreconditionsforexecutionofeachtask:tasksareexecutedonlywhentheirpreconditionsaresatisfied.Definedpreconditionsthroughdependencies:Executionstatesofothertasks.

“taskticannotstartuntiltasktj

hasended”Outputvaluesofothertasks. “taskticanstartiftasktjreturnsavaluegreaterthan25”Externalvariables,thataremodifiedbyexternalevents.

“tasktimustbestartedwithin24hoursofthecompletionoftasktj”14Workflow

Specification(Cont.)Dynamictaskcoordination

E.g.Electronicmailroutingsysteminwhichthetexttobescheduleforagivenmailmessagedependsonthedestinationaddressandonwhichintermediateroutersarefunctioning.15Failure-AutomicityRequirementsUsualACIDtransactionalrequirementsaretoostrong/unimplementableforworkflowapplications.However,workflowsmustsatisfysomelimitedtransactionalpropertiesthatguaranteeaprocessisnotleftinaninconsistentstate.Acceptableterminationstates-everyexecutionofaworkflowwillterminateinastatethatsatisfiesthefailure-atomicityrequirementsdefinedbythedesigner.Committed-objectivesofaworkflowhavebeenachieved.Aborted-validterminationstateinwhichaworkflowhasfailedtoachieveitsobjectives.Aworkflowmustreachanacceptableterminationstateeveninthepresenceofsystemfailures.16ExecutionofWorkflowsWorkflowmanagementsystemsinclude:Scheduler-programthatprocessworkflowsbysubmittingvarioustasksforexecution,monitoringvariousevents,andevaluationconditionsrelatedtointertaskdependenciesTaskagents-controltheexecutionofataskbyaprocessingentity.Mechanismtoquerytostateoftheworkflowsystem.17WorkflowManagementSystemArchitecturesCentralized-asingleschedulerschedulesthetasksforallconcurrentlyexecutingworkflows.usedinworkflowsystemswherethedataisstoredinacentraldatabase.easiertokeeptrackofthestateofaworkflow.Partiallydistributed-hasone(instanceofa)schedulerforeachworkflow.Fullydistributed-hasnoscheduler,butthetaskagentscoordinatetheirexecutionbycommunicatingwitheachothertosatisfytaskdependenciesandotherworkflowexecutionrequirements.usedinsimplestworkflowexecutionsystemsbasedonelectronicmail18WorkflowSchedulerIdeallyschedulershouldexecuteaworkflowonlyafterensuringthatitwillterminateinanacceptablestate.ConsideraworkflowconsistingoftwotasksS1andS2.Letthefailure-atomicityrequirementbethateitherbothorneitherofthesubtransactionsshouldbecommitted.SupposesystemsexecutingS1andS2donotprovideprepared-to-commitstatesandS1orS2donothavecompensatingtransactions.Itisthenpossibletoreachastatewhereonesubtransactioniscommittedandtheotheraborted.Bothcannotthenbebroughttothesamestate.Workflowspecificationisunsafe,andshouldberejected.Determinationofsafetybytheschedulerisnotpossibleingeneral,andisusuallylefttothedesigneroftheworkflow.19RecoveryofaWorkflowEnsurethatisafailureoccursinanyoftheworkflow-processingcomponents,theworkfloweventuallyreachesanacceptableterminationstate.Failure-recoveryroutinesneedtorestorethestateinformationofthescheduleratthetimeoffailure,includingtheinformationabouttheexecutionstatesofeachtask.Logstatusinformationonstablestorage.Handoffoftasksbetweenagentsshouldoccurexactlyonceinspiteoffailure.Problem:Repeatinghandoffonrecoverymayleadtoduplicateexecutionoftask;notrepeatinghandoffmayleadtotasknotbeingexecuted.Solution:Persistentmessagingsystems20RecoveryofaWorkflow(Cont.)Persistentmessages:messagesarestoredinpermanentmessagequeueandthereforenotlostincaseoffailure.DescribedindetailinChapter19(DistributedDatabases)Beforeanagentcommits,itwritestothepersistentmessagequeuewhatevermessagesneedtobesentout.Thepersistentmessagesystemmustmakesurethemessagesgetdeliveredeventuallyifandonlyifthetransactioncommits.Themessagesystemneedstoresendamessagewhenthesiterecovers,ifthemessageisnotknowntohavereacheditsdestination.Messagesmustbeloggedinstablestorageatthereceivingendtodetectmultiplereceiptsofamessage.21HighPerformance

TransactionSystems22Copyright:Silberschatz,KorthandSudarshanHigh-PerformanceTransactionSystemsHigh-performancehardwareandparallelismhelpimprovetherateoftransactionprocessing,butareinsufficienttoobtainhighperformance:DiskI/Oisabottleneck—I/Otime(10milliseconds)hasnodecreasedataratecomparabletotheincreaseinprocessorspeeds.Paralleltransactionsmayattempttoreadorwritethesamedataitem,resultingindataconflictsthatreduceeffectiveparallelismWecanreducethedegreetowhichadatabasesystemisdiskboundbyincreasingthesizeofthedatabasebuffer.23Main-MemoryDatabaseCommercial64-bitsystemscansupportmainmemoriesoftensofgigabytes.Memoryresidentdataallowsfasterprocessingoftransactions.Disk-relatedlimitations:Loggingisabottleneckwhentransactionrateishigh.Usegroup-committoreducenumberofoutputoperations(Willstudytwoslidesahead.)Iftheupdaterateformodifiedbufferblocksishigh,thediskdata-transferratecouldbecomeabottleneck.Ifthesystemcrashes,allofmainmemoryislost.24Main-MemoryDatabaseOptimizationsToreducespaceoverheads,main-memorydatabasescanusestructureswithpointerscrossingmultiplepages.Indiskdatabases,theI/Ocosttotraversemultiplepageswouldbeexcessivelyhigh.Noneedtopinbufferpagesinmemorybeforedataareaccessed,sincebufferpageswillneverbereplaced.Designquery-processingtechniquestominimizespaceoverhead-avoidexceedingmainmemorylimitsduringqueryevaluation.Improveimplementationofoperationssuchaslockingandlatching,sotheydonotbecomebottlenecks.Optimizerecoveryalgorithms,sincepagesrarelyneedtobewrittenouttomakespaceforotherpages.25GroupCommitIdea:Insteadofperformingoutputoflogrecordstostablestorageassoonasatransactionisreadytocommit,waituntillogbufferblockisfull,oratransactionhasbeenwaitingsufficientlylongafterbeingreadytocommitResultsinfeweroutputoperationspercommittedtransaction,andcorrespondinglyahigherthroughput.However,commitsaredelayeduntilasufficientlylargegroupoftransactionsarereadytocommit,oratransactionhasbeenwaitinglongenough-leadstoslightlyincreasedresponsetime.Abovedelayacceptableinhigh-performancetransactionsystemssincelogbufferblockswillfillupquickly.26Real-TimeTransactionSystemsInsystemswithreal-timeconstraints,correctnessofexecutioninvolvesbothdatabaseconsistencyandthesatisfactionofdeadlines.Harddeadline–SeriousproblemsmayoccuriftaskisnotcompletedwithindeadlineFirmdeadline-Thetaskhaszerovalueifitcompletedafterthedeadline.Softdeadline-Thetaskhasdiminishingvalueifitiscompletedafterthedeadline.Thewidevarianceofexecutiontimesforreadandwriteoperationsondiskscomplicatesthetransactionmanagementproblemfortime-constrainedsystemsmain-memorydatabasesarethusoftenusedWaitsforlocks,transactionaborts,contentionforresourcesremainasproblemsevenifdataisinmainmemoryDesignofareal-timesysteminvolvesensuringthatenoughprocessingpowerexiststomeetdeadlinewithoutrequiringexcessivehardwareresources.27LongDurationTransactionsTraditionalconcurrencycontroltechniquesdonotworkwellwhenuserinteractionisrequired:Longduration:DesigneditsessionsareverylongExposureofuncommitteddata:E.g.,partialupdatetoadesignSubtasks:supportpartialrollbackRecoverability:oncrashstateshouldberestoredevenforyet-to-becommitteddata,souserworkisnotlost.Performance:fastresponsetimeisessentialsousertimeisnotwasted.28Long-DurationTransactionsRepresentasanestedtransactionatomicdatabaseoperations(read/write)atalowestlevel.Iftransactionfails,onlyactiveshort-durationtransactionsabort.Activelong-durationtransactionsresumeonceanyshortdurationtransactionshaverecovered.Theefficientmanagementoflong-durationwaits,andthepossibilityofaborts.Needalternativestowaitsandaborts;alternativetechniquesmustensurecorrectnesswithoutrequiringserializability.29ConcurrencyControlCorrectnesswithoutserializability:Correctnessdependsonthespecificconsistencyconstraintsforthedatabases.Correctnessdependsonthepropertiesofoperationsperformedbyeachtransaction.Usedatabaseconsistencyconstraintsastosplitthedatabaseintosubdatabasesonwhichconcurrencycanbemanagedseparately.Treatsomeoperationsbesidesreadandwriteasfundamentallow-leveloperationsandextendconcurrencycontroltodealwiththem.30ConcurrencyControl(Cont.)Anon-conflict-serializableschedulethatpreservesthesumofA+B31NestedandMultilevelTransactionsAnestedormultileveltransaction

Tisrepresentedbyaset

T={t1,t2,...,tn}ofsubtransactionsandapartialorderPonT.Asubtransaction

tiinTmayabortwithoutforcingTtoabort.Instead,Tmayeitherrestartti,orsimplychoosenottorunti.If

ticommits,thisactiondoesnotmake

ti,permanent(unlikethesituationinChapter15).Instead,ti,commitstoT,andmaystillabort(orrequirecompensation)ifTaborts.AnexecutionofTmustnotviolatethepartialorderP,i.e.,ifanedgeti

ti

appearsintheprecedencegraph,thentiti

mustnotbeinthetransitiveclosureofP.32NestedandMultilevelTransactions(Cont.)Subtransactionscanthemselvesbenested/multileveltransactions.Lowestlevelofnesting:standardreadandwriteoperations.Nestingcancreatehigher-leveloperationsthatmayenhanceconcurrency.Typesofnested/multileveltransactions:Multileveltransaction:subtransactionofTispermittedtoreleaselocksoncompletion.Saga:multilevellong-durationtransaction.Nestedtransaction:locksheldbyasubtransactiontiofTareautomaticallyassigntoToncompletionofti.33ExampleofNestingRewritetransactionT1usingsubtransactionsTaandTbthatperformincrementordecrementoperations:T1consistsofT1,1,whichsubtracts50fromAT1,2,whichadds50toBRewritetransactionT2usingsubtransactionsTcandTdthatperformincrementordecrementoperations:T2consistsofT2,1,whichsubtracts10fromBT2,2,whichadds10toANoorderingisspecifiedonsubtransactions;anyexecutiongeneratesacorrectresult.34CompensatingTransactionsAlternativetoundooperation;compensatingtransactionsdealwiththeproblemofcascadingrollbacks.Insteadofundoingallchangesmadebythefailedtransaction,actionistakento“compensate”forthefailure.Consideralong-durationtransactionTirepresentingatravelreservation,withsubtransactionsTi,1,whichmakesairlinereservations,Ti,2whichreservesrentalcars,andTi,3whichreservesahotelroom.Hotelcancelsthereservation.InsteadofundoingallofTi,thefailureofTi,3iscompensatedforbydeletingtheoldhotelreservationandmakinganewone.Requiresuseofsemanticsofthefailedtransaction.35ImplementationIssuesForlong-durationtransactionstosurvivesystemcrashes,wemustlognotonlychangestothedatabase,butalsochangestointernalsystemdatapertainingtothesetransactions.Loggingofupdatesismademorecomplexbyphysicallylargedataitems(CADdesign,documenttext);undesirabletostorebotholdandnewvalues.Twoapproachestoreducingtheoverheadofensuringtherecoverabilityoflargedataitems:Operationlogging.Onlytheoperationperformedonthedataitemandthedata-itemnamearestoredinthelog.Loggingandshadowpaging.Useloggingfromsmalldataitems;useshadowpagingforlargedataitems.Onlymodifiedpagesneedtobestoredinduplicate.36TransactionManagementinMultidatabaseSystemsTransactionmanagementiscomplicatedinmultidatabasesystemsbecauseoftheassumptionofautonomyGlobal2PL-eachlocalsiteusesastrict2PL(locksarereleasedattheend);lockssetasaresultofaglobaltransactionarereleasedonlywhenthattransactionreachestheend.GuaranteesglobalserializabilityDuetoautonomyrequirements,sitescannotcooperateandexecuteacommonconcurrencycontrolschemeE.g.nowaytoensurethatalldatabasesfollowstrict2PLSolutions:provideverylowlevelofconcurrentexecution,oruseweakerlevelsofconsistency37TransactionManagementLocaltransactionsareexecutedbyeachlocalDBMS,outsideoftheMDBSsystemcontrol.Globaltransactionsareexecutedundermultidatabasecontrol.Localautonomy-localDBMSscannotcommunicatedirectlytosynchronizeglobaltransactionexecutionandthemultidatabasehasnocontroloverlocaltransactionexecution.localconcurrencycontrolschemeneededtoensurethatDBMS’sscheduleisserializableincaseoflocking,DBMSmustbeabletoguardagainstlocaldeadlocks.needadditionalmechanismstoensureglobalserializability38Two-LevelSerializabilityDBMSensureslocalserializabilityamongitslocaltransactions,includingthosethatarepartofaglobaltransaction.Themultidatabaseensuresserializabilityamongglobaltransactionsalone-ignoringtheorderingsinducedbylocaltransactions.2LSRdoesnotensureglobalserializability,however,itcanfulfillrequirementsforstrongcorrectness.1.Preserveconsistencyasspecifiedbyagivensetofconstraints2.GuaranteethatthesetofdataitemsreadbyeachtransactionisconsistentGlobal-readprotocol

:Globaltransactionscanread,butnotupdate,localdataitems;localtransactionsdonothaveaccesstoglobaldata.Therearenoconsistencyconstraintsbetweenlocalandglobaldataitems.39Two-LevelSerializability(Cont.)Local-readprotocol:Localtransactionshavereadaccesstoglobaldata;disallowsallaccesstolocaldatabyglobaltransactions.Atransactionhasavaluedependencyifthevaluethatitwritestoadataitematonesitedependsonavaluethatitreadforadataitemonanothersite.Forstrongcorrectness:Notransactionmayhaveavaluedependency.Global-read-write/local-readprotocol;Localtransactionshavereadaccesstoglobaldata;globaltransactionsmayreadandwritealldata;Noconsistencyconstraintsbetweenlocalandglobaldataitems.Notransactionmayhavevaluedependency.40GlobalSerializabilityEvenifnoinformationisavailableconcerningthestructu

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论