110 likes | 320 Views
Chapter 18.5: An Architecture for a Locking Scheduler. Loc Nguyen Class ID: 213 Feb 27, 2008. Overview. Assume knowledge of: Lock Two phase lock Lock modes: shared, exclusive, update Consider a simple scheduler that: Insert locks for transaction Release locks when told. Lock table.
E N D
Chapter 18.5: An Architecture for a Locking Scheduler Loc Nguyen Class ID: 213 Feb 27, 2008 Loc Nguyen
Overview • Assume knowledge of: • Lock • Two phase lock • Lock modes: shared, exclusive, update • Consider a simple scheduler that: • Insert locks for transaction • Release locks when told Loc Nguyen
Lock table Two-part Scheduler transactions R(A); W(B); COMMIT(T); … Scheduler, Part I LOCK(A); R(A); … Scheduler, Part II R(A); W(B); … DB Loc Nguyen
Semantics of Two-part Scheduler • Part I: select & insert appropriate lock modes to db operations (read,write, or update) • Part II: take actions (a lock or db operation) from Part I • Determine the transaction (T) that action belongs and status of T (delayed or not) Loc Nguyen
Semantics (Cont’d) • If T is delayed, action is delayed and added to wait list • If not, • Action is db operation, to be executed • Is lock, check lock table • Granted, update lock table w. granted entry • Else, update lock table w. lock request; delay further actions for T until lock granted Loc Nguyen
Semantics (Cont’d) • When T is done (commits or aborts), transaction manager (belongs to T) notify Part I to release all locks, if exists waiting lock, Part I notifies Part II • Part II when notified, determines next transaction T’ to get lock to continue. Loc Nguyen
A Tran Mode Wait Tnext Next B T1 S no U no T2 Group mode: U Waiting: yes X yes T3 List: <pointer> S no T1 The Lock Table • Group modes: • - S: only shared locks • U: one update lock and zero or • shared locks • X: one exclusive lock • and no other locks Loc Nguyen
A Tran Mode Wait Tnext Next B T1 S no U no T2 Group mode: U Waiting: yes X yes T3 List: <pointer> S no T1 Handling Lock Requests • SL1(A): • GM=S;W=N • UL2(A): • GM=U;W=N • XL3(A): • GM=U;W=Y Loc Nguyen
A Tran Mode Wait Tnext Next B T1 S no U no T2 Group mode: U Waiting: yes X yes T3 List: <pointer> S no T1 Handling Unlock Requests • Remove entry • Update group mode • Same as group mode, no action • Diff; then check entire list for new group mode • S: GM(S) or nothing • U: GM(S) or nothing • X: nothing • Update wait if “yes” • 1st come 1st serve • Prio. shared locks • Prio. upgrading Loc Nguyen
Q & A • Thank you! Loc Nguyen