- 1.65 MB
- 2022-04-29 14:33:37 发布
- 1、本文档共5页,可阅读全部内容。
- 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
- 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
- 文档侵权举报电话:19940600175。
'Chapter26:AdvancedTransactionProcessing
Chapter26:AdvancedTransactionProcessingTransaction-ProcessingMonitorsTransactionalWorkflowsHigh-PerformanceTransactionSystemsMainmemorydatabasesReal-TimeTransactionSystemsLong-DurationTransactionsTransactionmanagementinmultidatabasesystems
TransactionProcessingMonitorsTPmonitorsinitiallydevelopedasmultithreadedserverstosupportlargenumbersofterminalsfromasingleprocess.Provideinfrastructureforbuildingandadministeringcomplextransactionprocessingsystemswithalargenumberofclientsandmultipleservers.Provideservicessuchas:PresentationfacilitiestosimplifycreatinguserinterfacesPersistentqueuingofclientrequestsandserverresponsesRoutingofclientmessagestoserversCoordinationoftwo-phasecommitwhentransactionsaccessmultipleservers.SomecommercialTPmonitors:CICSfromIBM,PathwayfromTandem,TopEndfromNCR,andEncinafromTransarc
TPMonitorArchitectures
TPMonitorArchitectures(Cont.)Processperclientmodel-insteadofindividualloginsessionperterminal,serverprocesscommunicateswiththeterminal,handlesauthentication,andexecutesactions.MemoryrequirementsarehighMultitasking-highCPUoverheadforcontextswitchingbetweenprocessesSingleprocessmodel-allremoteterminalsconnecttoasingleserverprocess.Usedinclient-serverenvironmentsServerprocessismulti-threaded;lowcostforthreadswitchingNoprotectionbetweenapplicationsNotsuitedforparallelordistributeddatabases
TPMonitorArchitectures(Cont.)Many-serversingle-routermodel-multipleapplicationserverprocessesaccessacommondatabase;clientscommunicatewiththeapplicationthroughasinglecommunicationprocessthatroutesrequests.IndependentserverprocessesformultipleapplicationsMultithreadserverprocessRunonparallelordistributeddatabaseManyservermany-routermodel-multipleprocessescommunicatewithclients.Clientcommunicationprocessesinteractwithrouterprocessesthatroutetheirrequeststotheappropriateserver.Controllerprocessstartsupandsupervisesotherprocesses.
DetailedStructureofaTPMonitor
DetailedStructureofaTPMonitorQueuemanagerhandlesincomingmessagesSomequeuemanagersprovidepersistentordurablemessagequeueingcontentsofqueuearesafeevenifsystemsfails.Durablequeueingofoutgoingmessagesisimportantapplicationserverwritesmessagetodurablequeueaspartofatransactiononcethetransactioncommits,theTPmonitorguaranteesmessageiseventuallydelivered,regardlessofcrashes.ACIDpropertiesarethusprovidedevenformessagessentoutsidethedatabaseManyTPmonitorsprovidelocking,loggingandrecoveryservices,toenableapplicationserverstoimplementACIDpropertiesbythemselves.
ApplicationCoordinationUsingTPMonitorsATPmonitortreatseachsubsystemasaresourcemanagerthatprovidestransactionalaccesstosomesetofresources.TheinterfacebetweentheTPmonitorandtheresourcemanagerisdefinedbyasetoftransactionprimitivesTheresourcemanagerinterfaceisdefinedbytheX/OpenDistributedTransactionProcessingstandard.TPmonitorsystemsprovideatransactionalremoteprocedurecall(transactionalRPC)interfacetotheirserviceTransactionalRPCprovidescallstoencloseaseriesofRPCcallswithinatransaction.UpdatesperformedbyanRPCarecarriedoutwithinthescopeofthetransaction,andcanberolledbackifthereisanyfailure.
WorkflowSystems
TransactionalWorkflowsWorkflowsareactivitiesthatinvolvethecoordinatedexecutionofmultipletasksperformedbydifferentprocessingentities.Withthegrowthofnetworks,andtheexistenceofmultipleautonomousdatabasesystems,workflowsprovideaconvenientwayofcarryingouttasksthatinvolvemultiplesystems.Exampleofaworkflowdeliveryofanemailmessage,whichgoesthroughseveralmailssystemstoreachdestination.Eachmailerperformsatasks:forwardingofthemailtothenextmailer.Ifamailercannotdelivermail,failuremustbehandledsemantically(deliveryfailuremessage).Workflowsusuallyinvolvehumans:e.g.loanprocessing,orpurchaseorderprocessing.
ExamplesofWorkflows
LoanProcessingWorkflowInthepast,workflowswerehandledbycreatingandforwardingpaperformsComputerizedworkflowsaimtoautomatemanyofthetasks.Butthehumansstillplayrolee.g.,inapprovingloans.
TransactionalWorkflowsMustaddressfollowingissuestocomputerizeaworkflow.Specificationofworkflows-detailingthetasksthatmustbecarriedoutanddefiningtheexecutionrequirements.Executionofworkflows-executetransactionsspecifiedintheworkflowwhilealsoprovidingtraditionaldatabasesafeguardsrelatedtothecorrectnessofcomputations,dataintegrity,anddurability.E.g.:Loanapplicationshouldnotgetlostevenifsystemfails.Extendtransactionconceptstothecontextofworkflows.Stateofaworkflow-consistsofthecollectionofstatesofitsconstituenttasks,andthestates(i.e.,values)ofallvariablesintheexecutionplan.
WorkflowSpecificationStaticspecificationoftaskcoordination:Tasksanddependenciesamongthemaredefinedbeforetheexecutionoftheworkflowstarts.Canestablishpreconditionsforexecutionofeachtask:tasksareexecutedonlywhentheirpreconditionsaresatisfied.Definedpreconditionsthroughdependencies:Executionstatesofothertasks.“taskticannotstartuntiltasktjhasended”Outputvaluesofothertasks.“taskticanstartiftasktjreturnsavaluegreaterthan25”Externalvariables,thataremodifiedbyexternalevents.“tasktimustbestartedwithin24hoursofthecompletionoftasktj”
WorkflowSpecification(Cont.)DynamictaskcoordinationE.g.,Electronicmailroutingsysteminwhichthetexttobescheduleforagivenmailmessagedependsonthedestinationaddressandonwhichintermediateroutersarefunctioning.
Failure-AutomicityRequirementsUsualACIDtransactionalrequirementsaretoostrong/unimplementableforworkflowapplications.However,workflowsmustsatisfysomelimitedtransactionalpropertiesthatguaranteeaprocessisnotleftinaninconsistentstate.Acceptableterminationstates-everyexecutionofaworkflowwillterminateinastatethatsatisfiesthefailure-atomicityrequirementsdefinedbythedesigner.Committed-objectivesofaworkflowhavebeenachieved.Aborted-validterminationstateinwhichaworkflowhasfailedtoachieveitsobjectives.Aworkflowmustreachanacceptableterminationstateeveninthepresenceofsystemfailures.
ExecutionofWorkflowsWorkflowmanagementsystemsinclude:Scheduler-programthatprocessworkflowsbysubmittingvarioustasksforexecution,monitoringvariousevents,andevaluationconditionsrelatedtointertaskdependenciesTaskagents-controltheexecutionofataskbyaprocessingentity.Mechanismtoquerytostateoftheworkflowsystem.
WorkflowManagementSystemArchitecturesCentralized-asingleschedulerschedulesthetasksforallconcurrentlyexecutingworkflows.usedinworkflowsystemswherethedataisstoredinacentraldatabase.easiertokeeptrackofthestateofaworkflow.Partiallydistributed-hasone(instanceofa)schedulerforeachworkflow.Fullydistributed-hasnoscheduler,butthetaskagentscoordinatetheirexecutionbycommunicatingwitheachothertosatisfytaskdependenciesandotherworkflowexecutionrequirements.usedinsimplestworkflowexecutionsystemsbasedonelectronicmail
WorkflowSchedulerIdeallyschedulershouldexecuteaworkflowonlyafterensuringthatitwillterminateinanacceptablestate.ConsideraworkflowconsistingoftwotasksS1andS2.Letthefailure-atomicityrequirementbethateitherbothorneitherofthesubtransactionsshouldbecommitted.SupposesystemsexecutingS1andS2donotprovideprepared-to-commitstatesandS1orS2donothavecompensatingtransactions.Itisthenpossibletoreachastatewhereonesubtransactioniscommittedandtheotheraborted.Bothcannotthenbebroughttothesamestate.Workflowspecificationisunsafe,andshouldberejected.Determinationofsafetybytheschedulerisnotpossibleingeneral,andisusuallylefttothedesigneroftheworkflow.
RecoveryofaWorkflowEnsurethatisafailureoccursinanyoftheworkflow-processingcomponents,theworkfloweventuallyreachesanacceptableterminationstate.Failure-recoveryroutinesneedtorestorethestateinformationofthescheduleratthetimeoffailure,includingtheinformationabouttheexecutionstatesofeachtask.Logstatusinformationonstablestorage.Handoffoftasksbetweenagentsshouldoccurexactlyonceinspiteoffailure.Problem:Repeatinghandoffonrecoverymayleadtoduplicateexecutionoftask;notrepeatinghandoffmayleadtotasknotbeingexecuted.Solution:Persistentmessagingsystems
RecoveryofaWorkflow(Cont.)Persistentmessages:messagesarestoredinpermanentmessagequeueandthereforenotlostincaseoffailure.DescribedindetailinChapter19(DistributedDatabases)Beforeanagentcommits,itwritestothepersistentmessagequeuewhatevermessagesneedtobesentout.Thepersistentmessagesystemmustmakesurethemessagesgetdeliveredeventuallyifandonlyifthetransactioncommits.Themessagesystemneedstoresendamessagewhenthesiterecovers,ifthemessageisnotknowntohavereacheditsdestination.Messagesmustbeloggedinstablestorageatthereceivingendtodetectmultiplereceiptsofamessage.
HighPerformanceTransactionSystems
High-PerformanceTransactionSystemsHigh-performancehardwareandparallelismhelpimprovetherateoftransactionprocessing,butareinsufficienttoobtainhighperformance:DiskI/Oisabottleneck—I/Otime(10milliseconds)hasnodecreasedataratecomparabletotheincreaseinprocessorspeeds.Paralleltransactionsmayattempttoreadorwritethesamedataitem,resultingindataconflictsthatreduceeffectiveparallelismWecanreducethedegreetowhichadatabasesystemisdiskboundbyincreasingthesizeofthedatabasebuffer.
Main-MemoryDatabaseCommercial64-bitsystemscansupportmainmemoriesoftensofgigabytes.Memoryresidentdataallowsfasterprocessingoftransactions.Disk-relatedlimitations:Loggingisabottleneckwhentransactionrateishigh.Usegroup-committoreducenumberofoutputoperations(Willstudytwoslidesahead.)Iftheupdaterateformodifiedbufferblocksishigh,thediskdata-transferratecouldbecomeabottleneck.Ifthesystemcrashes,allofmainmemoryislost.
Main-MemoryDatabaseOptimizationsToreducespaceoverheads,main-memorydatabasescanusestructureswithpointerscrossingmultiplepages.Indiskdatabases,theI/Ocosttotraversemultiplepageswouldbeexcessivelyhigh.Noneedtopinbufferpagesinmemorybeforedataareaccessed,sincebufferpageswillneverbereplaced.Designquery-processingtechniquestominimizespaceoverhead-avoidexceedingmainmemorylimitsduringqueryevaluation.Improveimplementationofoperationssuchaslockingandlatching,sotheydonotbecomebottlenecks.Optimizerecoveryalgorithms,sincepagesrarelyneedtobewrittenouttomakespaceforotherpages.
GroupCommitIdea:Insteadofperformingoutputoflogrecordstostablestorageassoonasatransactionisreadytocommit,waituntillogbufferblockisfull,oratransactionhasbeenwaitingsufficientlylongafterbeingreadytocommitResultsinfeweroutputoperationspercommittedtransaction,andcorrespondinglyahigherthroughput.However,commitsaredelayeduntilasufficientlylargegroupoftransactionsarereadytocommit,oratransactionhasbeenwaitinglongenough-leadstoslightlyincreasedresponsetime.Abovedelayacceptableinhigh-performancetransactionsystemssincelogbufferblockswillfillupquickly.
Real-TimeTransactionSystemsInsystemswithreal-timeconstraints,correctnessofexecutioninvolvesbothdatabaseconsistencyandthesatisfactionofdeadlines.Harddeadline–SeriousproblemsmayoccuriftaskisnotcompletedwithindeadlineFirmdeadline-Thetaskhaszerovalueifitcompletedafterthedeadline.Softdeadline-Thetaskhasdiminishingvalueifitiscompletedafterthedeadline.Thewidevarianceofexecutiontimesforreadandwriteoperationsondiskscomplicatesthetransactionmanagementproblemfortime-constrainedsystemsmain-memorydatabasesarethusoftenusedWaitsforlocks,transactionaborts,contentionforresourcesremainasproblemsevenifdataisinmainmemoryDesignofareal-timesysteminvolvesensuringthatenoughprocessingpowerexiststomeetdeadlinewithoutrequiringexcessivehardwareresources.
LongDurationTransactionsTraditionalconcurrencycontroltechniquesdonotworkwellwhenuserinteractionisrequired:Longduration:DesigneditsessionsareverylongExposureofuncommitteddata:E.g.,partialupdatetoadesignSubtasks:supportpartialrollbackRecoverability:oncrashstateshouldberestoredevenforyet-to-becommitteddata,souserworkisnotlost.Performance:fastresponsetimeisessentialsousertimeisnotwasted.
Long-DurationTransactionsRepresentasanestedtransactionatomicdatabaseoperations(read/write)atalowestlevel.Iftransactionfails,onlyactiveshort-durationtransactionsabort.Activelong-durationtransactionsresumeonceanyshortdurationtransactionshaverecovered.Theefficientmanagementoflong-durationwaits,andthepossibilityofaborts.Needalternativestowaitsandaborts;alternativetechniquesmustensurecorrectnesswithoutrequiringserializability.
ConcurrencyControlCorrectnesswithoutserializability:Correctnessdependsonthespecificconsistencyconstraintsforthedatabases.Correctnessdependsonthepropertiesofoperationsperformedbyeachtransaction.Usedatabaseconsistencyconstraintsastosplitthedatabaseintosubdatabasesonwhichconcurrencycanbemanagedseparately.Treatsomeoperationsbesidesreadandwriteasfundamentallow-leveloperationsandextendconcurrencycontroltodealwiththem.
ConcurrencyControl(Cont.)Anon-conflict-serializableschedulethatpreservesthesumofA+B
NestedandMultilevelTransactionsAnestedormultileveltransactionTisrepresentedbyasetT={t1,t2,...,tn}ofsubtransactionsandapartialorderPonT.AsubtransactiontiinTmayabortwithoutforcingTtoabort.Instead,Tmayeitherrestartti,orsimplychoosenottorunti.Ifticommits,thisactiondoesnotmaketi,permanent(unlikethesituationinChapter15).Instead,ti,commitstoT,andmaystillabort(orrequirecompensation)ifTaborts.AnexecutionofTmustnotviolatethepartialorderP,i.e.,ifanedgetitiappearsintheprecedencegraph,thentitimustnotbeinthetransitiveclosureofP.
NestedandMultilevelTransactions(Cont.)Subtransactionscanthemselvesbenested/multileveltransactions.Lowestlevelofnesting:standardreadandwriteoperations.Nestingcancreatehigher-leveloperationsthatmayenhanceconcurrency.Typesofnested/multileveltransactions:Multileveltransaction:subtransactionofTispermittedtoreleaselocksoncompletion.Saga:multilevellong-durationtransaction.Nestedtransaction:locksheldbyasubtransactiontiofTareautomaticallyassigntoToncompletionofti.
ExampleofNestingRewritetransactionT1usingsubtransactionsTaandTbthatperformincrementordecrementoperations:T1consistsofT1,1,whichsubtracts50fromAT1,2,whichadds50toBRewritetransactionT2usingsubtransactionsTcandTdthatperformincrementordecrementoperations:T2consistsofT2,1,whichsubtracts10fromBT2,2,whichadds10toANoorderingisspecifiedonsubtransactions;anyexecutiongeneratesacorrectresult.
CompensatingTransactionsAlternativetoundooperation;compensatingtransactionsdealwiththeproblemofcascadingrollbacks.Insteadofundoingallchangesmadebythefailedtransaction,actionistakento“compensate”forthefailure.Consideralong-durationtransactionTirepresentingatravelreservation,withsubtransactionsTi,1,whichmakesairlinereservations,Ti,2whichreservesrentalcars,andTi,3whichreservesahotelroom.Hotelcancelsthereservation.InsteadofundoingallofTi,thefailureofTi,3iscompensatedforbydeletingtheoldhotelreservationandmakinganewone.Requiresuseofsemanticsofthefailedtransaction.
ImplementationIssuesForlong-durationtransactionstosurvivesystemcrashes,wemustlognotonlychangestothedatabase,butalsochangestointernalsystemdatapertainingtothesetransactions.Loggingofupdatesismademorecomplexbyphysicallylargedataitems(CADdesign,documenttext);undesirabletostorebotholdandnewvalues.Twoapproachestoreducingtheoverheadofensuringtherecoverabilityoflargedataitems:Operationlogging.Onlytheoperationperformedonthedataitemandthedata-itemnamearestoredinthelog.Loggingandshadowpaging.Useloggingfromsmalldataitems;useshadowpagingforlargedataitems.Onlymodifiedpagesneedtobestoredinduplicate.
TransactionManagementinMultidatabaseSystemsTransactionmanagementiscomplicatedinmultidatabasesystemsbecauseoftheassumptionofautonomyGlobal2PL-eachlocalsiteusesastrict2PL(locksarereleasedattheend);lockssetasaresultofaglobaltransactionarereleasedonlywhenthattransactionreachestheend.GuaranteesglobalserializabilityDuetoautonomyrequirements,sitescannotcooperateandexecuteacommonconcurrencycontrolschemeE.g.,nowaytoensurethatalldatabasesfollowstrict2PLSolutions:provideverylowlevelofconcurrentexecution,oruseweakerlevelsofconsistency
TransactionManagementLocaltransactionsareexecutedbyeachlocalDBMS,outsideoftheMDBSsystemcontrol.Globaltransactionsareexecutedundermultidatabasecontrol.Localautonomy-localDBMSscannotcommunicatedirectlytosynchronizeglobaltransactionexecutionandthemultidatabasehasnocontroloverlocaltransactionexecution.localconcurrencycontrolschemeneededtoensurethatDBMS’sscheduleisserializableincaseoflocking,DBMSmustbeabletoguardagainstlocaldeadlocks.needadditionalmechanismstoensureglobalserializability
Two-LevelSerializabilityDBMSensureslocalserializabilityamongitslocaltransactions,includingthosethatarepartofaglobaltransaction.Themultidatabaseensuresserializabilityamongglobaltransactionsalone-ignoringtheorderingsinducedbylocaltransactions.2LSRdoesnotensureglobalserializability,however,itcanfulfillrequirementsforstrongcorrectness.1.Preserveconsistencyasspecifiedbyagivensetofconstraints2.GuaranteethatthesetofdataitemsreadbyeachtransactionisconsistentGlobal-readprotocol:Globaltransactionscanread,butnotupdate,localdataitems;localtransactionsdonothaveaccesstoglobaldata.Therearenoconsistencyconstraintsbetweenlocalandglobaldataitems.
Two-LevelSerializability(Cont.)Local-readprotocol:Localtransactionshavereadaccesstoglobaldata;disallowsallaccesstolocaldatabyglobaltransactions.Atransactionhasavaluedependencyifthevaluethatitwritestoadataitematonesitedependsonavaluethatitreadforadataitemonanothersite.Forstrongcorrectness:Notransactionmayhaveavaluedependency.Global-read-write/local-readprotocol:Localtransactionshavereadaccesstoglobaldata;globaltransactionsmayreadandwritealldata;Noconsistencyconstraintsbetweenlocalandglobaldataitems.Notransactionmayhavevaluedependency.
GlobalSerializabilityEvenifnoinformationisavailableconcerningthestructureofthevariousconcurrencycontrolschemes,averyrestrictiveprotocolthatensuresserializabilityisavailable.Transaction-graph:agraphwithverticesbeingglobaltransactionnamesandsitenames.Anundirectededge(Ti,Sk)existsifTiisactiveatsiteSk.Globalserializabilityisassurediftransaction-graphcontainsnoundirectedcycles.
EnsuringGlobalSerializabilityEachsiteSihasaspecialdataitem,calledticketEverytransactionTjthatrunsatsiteSkwritestotheticketatsiteSiEnsuresglobaltransactionsareserializedateachsite,regardlessoflocalconcurrencycontrolmethod,solongasthemethodguaranteeslocalserializabilityGlobaltransactionmanagerdecidesserialorderingofglobaltransactionsbycontrollingorderinwhichticketsareaccessedHowever,aboveprotocolresultsinlowconcurrencybetweenglobaltransactions.
EndofChapter26
Figure26.01
Figure26.02
Figure26.03
Figure26.04
Figure26.05
Extraslides
WeakLevelsConsistencyUsealternativenotionsofconsistencythatdonotensureserializability,toimproveperformance.Degree-twoconsistencyavoidscascadingabortswithoutnecessarilyensuringserializability.Unliketwo-phaselocking,S-locksmaybereleasedatanytime,andlicksmaybeacquiredatanytime.X-locksbereleaseduntilthetransactioneithercommitsoraborts.
ExampleSchedulewithDegree-TwoConsistencyNonserializableschedulewithdegree-twoconsistency(Figure20.5)whereT3readsthevalueifQbeforeandafterthatvalueiswrittenbyT4.T3T4lock-S(Q)read(Q)unlock(Q)lock-S(Q)read(Q)unlock(Q)lock-X(Q)read(Q)write(Q)unlock(Q)
CursorStabilityFormofdegree-twoconsistencydesignedforprogramswritteningeneral-purpose,record-orientedlanguages(e.g.,Pascal,C,Cobol,PL/I,Fortran).Ratherthanlockingtheentirerelation,cursorstabilityensuresthatThetuplethatiscurrentlybeingprocessedbytheiterationislockedinsharedmode.Anymodifiedtuplesarelockedinexclusivemodeuntilthetransactioncommits.Usedonheavilyaccessedrelationsasameansofincreasingconcurrencyandimprovingsystemperformance.Useislimitedtospecializedsituationswithsimpleconsistencyconstraints.'
您可能关注的文档
- 数据结构课件PPT110章全 第五章 数组和广义表.ppt
- 数据结构课件PPT110章全 第六章 树和二叉树.ppt
- 数据结构课件PPT110章全 第七章 图.ppt
- 数据库系统概念全套配套课件PPT ch12.ppt
- 数据库系统概念全套配套课件PPT ch6.ppt
- 数据库系统概念全套配套课件PPT ch2.ppt
- 数据库系统概念全套配套课件PPT appB.ppt
- 数据库系统概念全套配套课件PPT ch16.ppt
- 数据库系统概念全套配套课件PPT ch7.ppt
- 数据库系统概念全套配套课件PPT ch22.ppt
- 数据库系统概念全套配套课件PPT ch23.ppt
- 数据库系统概念全套配套课件PPT ch21.ppt
- 数据库系统概念全套配套课件PPT ch15.ppt
- 土木工程材料第2版柯国军配套教学课件PPT 06土木工程材料.ppt
- 土木工程材料第2版柯国军配套教学课件PPT 01土木工程材料.ppt
- 土木工程材料第2版柯国军配套教学课件PPT 07土木工程材料.ppt
- 土木工程材料第2版柯国军配套教学课件PPT 14土木工程材料.ppt
- 土木工程材料第2版柯国军配套教学课件PPT 10土木工程材料.ppt