资源描述:
《[计算机软件及应用]数据库课件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、9.ConcurrencyControlJongHoonKimDATABASESYSTEMIMPLEMENTATIONHECTORGARCIA-MOLINAJEFFRYD.ULLMANJENIFERWIDOMGeneralprocessofassuringthattransactionspreserveconsistencywhenexecutingsimultaneously.TransactionmanagerSchedulerBuffersRead/WriterequestsReadsandwritesConcurrencyControlSchedulesCor
2、rectnessprincipleIfexecutedinisolation,everytransactionwilltransformanyconsistentstatetoanotherconsistentstate.However,transactionsoftenrunconcurrentlywithothertransactions,sothecorrectnessprincipledoesn’tapplydirectly.schedules:time-orderedsequenceoftheactionstakenbyoneormoretransactions-
3、>guaranteeddoproducethesameresultasiftransactionsexecutedone-at-a-timeWhenstudyingconcurrencycontrol,theimportantreadandwriteactionstakeplaceinthemain-memorybuffers,notdiskT1T2READ(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)theonlycon
4、sistencyconstraintonthedatabasestateisthatA=B.eachtransaction,runinisolation,willpreserveconsistencySchedules–Ex.9.1SerialSchedules:AscheduleSisserialifforanytwotransactionsTandT’,ifanyactionofTprecedesanyactionofT’,thenallactionsofTprecedesallactionsofT’T1T2AB2525READ(A,t)t:=t+100WRITE(A,
5、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(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)150SerializableScheduleseveryserialschedulewillpreserveconsistencyofdatabasest
6、ateserializable:ifitseffectonthedatabasestateisthesameasthatofsomeserialschedule,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,scheduleT1T2A
7、B2525READ(A,t)t:=t+100WRITE(A,t)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