Matakuliah Tahun Versi : M0184 / Pengolahan Data Distribusi : 2005 : Session – 12 CONCURRENCY CONTROL USER ACCESS CONTROL OBJECTIVES • The problem around user access control (concurrency transaction) • User access control – schedules and serialization Problem in Concurrent transaction • Lost Update problem • Violation of integrity constraint • Inconsistent retrieval problem Lost Update problem Begin transaction T1 read balance(x) balance(x) = balance(x)-100 Time if balance(x) < 0 then print “No Fund!” abort T1 end if write balance(x) write balance(y) balance(y) = balance(y)+100 write balance(y) Commit T1 Begin transaction T2 read balance(x) balance(x) = balance(x) + 100 write balance(x) Commit T2 Note : X = 100 The increase of X to 200 by T2 will be overwritten by the decrement to ) by T1, thereby losing 100 Violation by Integrity Constraint • When two transaction are allowed to execute concurrently without being synchronized. SURGEON SName Mary Tom Operation Tonsillectomy Tonsillectomy Mary Appendectomy SCHEDULE SName Operation Mary …….. Date Tonsillectomy 04.04.200 5 …………… ………. Violation by Integrity Constraint Begin transaction T3 read SCHEDULE where date= 04.04.2005 read SURGEON where SURGEON.SName = SCHEDULE.SName and SURGEON.Operation = “Appendectomy” if not found then abort T3 SCHEDULE.operation = “Appendectomy” Commit T3 Begin transaction T4 read SCHEDULE where date= 04.04.2005 read SURGEON where SURGEON.SName = “Tom” And SURGEON.Operation = SCHEDULE.Operat if not found then abort T4 SCHEDULE.SName = “Tom” Commit T4 Note :T3 changes the operation schedule on 04.04.2005 from a tonsillectomy to an appendectomy. T4 changes the surgeon assigned to 04.04.2005 to Tom. The effect of these two transaction is to produce database state which is inconsistent. Tom now is qualified to operate on 04.04.2005 and perform appendectomy, which is not qualified to do so, as shown in tables before. Inconsistent Retrieval Problem Begin transaction T1 read balance(x) balance(x) = balance(x)-100 if balance(x) < 0 then print “No Fund!” abort T1 end if write balance(x) write balance(y) balance(y) = balance(y)+100 write balance(y) Commit T1 Begin Transaction T5 sum = 0 do while not end of relation read balance(a) sum = sum + balance(a) :::: :::: read balance(x) sum = sum + balance(x) :::: :::: read balance(y) sum = sum + balance(y) :: Commit T5 Schedule and Serialization • A transaction consists pf a sequence of Reads and Writes to the database. The entire sequence of reads and writes by all concurrent transactions in database taken together is known as Schedule. A schedule S is generally written : S = [O1, O2, O3,O4,……,On] O : indicate Read or Write operation Schedule and Serialization Cont’d • A Serial Schedule is one in which all read and write of each transaction are grouped together so that the transaction are run sequentially one after the other. EXAMPLE T6 T7 Begin Transaction T7 Read X Time Begin Transaction T6 read Y Y=Y+1 write Y Commit T6 Read Y Y=Y+1 Write Y Commit T7 T8 Begin transaction T8 read X X=X+1 write X Commit T8 EXAMPLE Cont’d • The Schedule S for that example : S= [R7(X),R8(X),W8(X),R6(Y),W6(Y),R7(Y),W7(Y)] • Serial Schedule SR : SR = [R6(Y),W6(Y),R7(X),R7(Y),W7(Y),R8(X),W8(X)]
© Copyright 2026 Paperzz