资源描述:
《计算机软件及应用数据库课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、9.ConcurrencyControlJongHoonKimDATABASESYSTEMIMPLEMENTATIONHECTORGARCIA-MOLINAJEFFRYD.ULLMANJENIFERWIDOMGeneralprocessofassuringthattransactionspreserveconsistencywhenexecutingsimultaneously.TransactionmanagerSchedulerBuffersRead/WriterequestsReadsan
2、dwritesConcurrencyControlSchedulesCorrectnessprincipleIfexecutedinisolation,everytransactionwilltransformanyconsistentstatetoanotherconsistentstate.However,transactionsoftenrunconcurrentlywithothertransactions,sothecorrectnessprincipledoesn’tapplydirect
3、ly.schedules:time-orderedsequenceoftheactionstakenbyoneormoretransactions->guaranteeddoproducethesameresultasiftransactionsexecutedone-at-a-timeWhenstudyingconcurrencycontrol,theimportantreadandwriteactionstakeplaceinthemain-memorybuffers,notdiskT1T2REA
4、D(A,t)READ(A,s)t:=t+100s:=s*2WRITE(A,t)WRITE(A,s)READ(B,t)READ(B,s)t:=t+100s:=s*2WRITE(B,t)WRITE(B,s)theonlyconsistencyconstraintonthedatabasestateisthatA=B.eachtransaction,runinisolation,willpreserveconsistencySchedules–Ex.9.1SerialSchedules:AscheduleS
5、isserialifforanytwotransactionsTandT’,ifanyactionofTprecedesanyactionofT’,thenallactionsofTprecedesallactionsofT’T1T2AB2525READ(A,t)t:=t+100WRITE(A,t)125READ(B,t)t:=t+100WRITE(B,t)125READ(A,s)s:=s*2WRITE(A,s)250READ(B,s)s:=s*2WRITE(B,s)250T1T2AB2525READ
6、(A,s)s:=s*2WRITE(A,s)50READ(B,s)s:=s*2WRITE(B,s)50READ(A,t)t:=t+100WRITE(A,t)150READ(B,t)t:=t+100WRITE(B,t)150SerializableScheduleseveryserialschedulewillpreserveconsistencyofdatabasestateserializable:ifitseffectonthedatabasestateisthesameasthatofsomese
7、rialschedule,regardlessofwhattheinitialstateofthedatabaseisT1T2AB2525READ(A,t)t:=t+100WRITE(A,t)125READ(A,s)s:=s*2WRITE(A,s)250READ(B,t)t:=t+100WRITE(B,t)125READ(B,s)s:=s*2WRITE(B,s)250Aserializable,butserial,scheduleT1T2AB2525READ(A,t)t:=t+100WRITE(A,t
8、)125READ(A,s)s:=s*2WRITE(A,s)250READ(B,s)s:=s*2WRITE(B,s)50READ(B,t)t:=t+100WRITE(B,t)150NonerializableScheduleTheEffectofTransactionSemanticsT1T2AB2525READ(A,t)t:=t+100WRITE(A,t)125READ(A,s)s:=s*1WRITE(A,s)125READ(B,s)25s:=s*1WR