Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chap.7 Concurrency Control Algorithms on object

Similar presentations


Presentation on theme: "Chap.7 Concurrency Control Algorithms on object"— Presentation transcript:

1 Chap.7 Concurrency Control Algorithms on object
MM lab 전지열

2 CONTENTS 7.1 Goal and overview 7.2 Locking for Flat Object Transaction
7.3 Layered Locking 7.4 Locking on General Transaction Forests 7.5 Hybrid Algorithms 7.6 Locking for Return Value Commutativity and Escrow Locking

3 7.1 Goal and overview We will Introduce concurrency control algorithms for systems based on the object model Tree reducible schedules where all level-to level schedules are OCSR or CSR and conflict faithful We will assume that commutativity is specified as a simple table on a per-object type or on a per-layer basis

4 7.2 Locking for Flat Object Transactions
2PL for Flat Object Schedules Lock acquisition rule: L1 operation f(x) needs to lock x in f mode Lock release rule: Once an L1 lock of f(x) is released, no other L1 lock can be acquired. Example deposit(a) deposit(b) withdraw (c) withdraw(a) t1 t2 a가 unlock이 되기를 기다림

5 7.3 Layered Locking The order-preserving conflict serializability of the level-to level High level operation can be executed concurrently on lower levels This can in turn be guaranteed by applying an appropriate flat concurrency control protocol between each pair of adjacent levels 2PL, S2PL, SS2PL Modular architecture The operations at level Li (children) The identifiers of their Li+1 (parent)

6 7.3 Layered Locking Layered 2PL for n-level schedules
Lock acquisition rule: Li operation f(x) with parent p, which is now a subtransaction, f-mode lock on x needs to be acquired before the operation can start its execution  Li lock Lock release rule: Once an Li lock of f(x) with parent p is released, no other child of p can acquire any locks. Subtransaction rule: At the termination of an Li operation f(x), all L(i-1) locks acquired for children of f(x) are released

7 7.3 Layered Locking Theorem 7.1:
Layered 2PL generates only tree reducible schedules. Proof: All level-to-level schedules are OCSR, hence the claim (by Theorem 6.2). Proof: Order - preserving conflict serializability from level 1 to level 0 allows us to apply the ordering and commutativity rules to isolate the subtrees rooted at level L1 such that the execution order of L1 is preserved. Then we can prune all operations of L0 by the tree pruning rule. Theorem 6.2: Let s be an n-level object model schedule. If for each i, 0<i≤n, the Li to Li-1 schedule derived from s is order preserving conflict serializable, then s is tree reducible

8 7.3 Layered Locking Special case – page latches for single-page record operation Fetch(x) operation – latch the affected pate during the record operation Acquiring a “full-fledged” page lock Commercial database – latching avoids expensive operation system calls as much as possible Latching does not provide higher concurrency Its overhead is much lower than that of a lock manager

9 7.3 Layered Locking t1 t2 t11 t21 L1 L0 t12 t13 t22 store(z) modify(y)
fetch(x) modify(y) r(t) r(p) t1 t2 t11 t21 L1 L0 store(z) modify(w) r(q) w(q) w(p) w(t) t12 t13 t22 Figure 7.2 Layered 2PL applied to the record and page levels of a two level schedule

10 7.3 Layered Locking(Cont.)
3-Level Example t1 t2 Insert Into Persons Values (Name=..., City="Austin", Age=29, ...) Select Name From Persons Where City="Seattle" And Age=29 Select Name From Persons Where Age=30 store(x) insert (CityIndex, "Austin", @x) search (CityIndex, "Seattle") insert (AgeIndex, search (AgeIndex, 29) fetch(y) search (AgeIndex, 30) fetch(z) r(p) w(p) r(r) r(n) r(r) r(l) r(n) w(l) r(l) r(r’) r(n’) r(l’) r(r’) r(n’) r(l’) w(l’) r(p) w(p) r(r’) r(n’) r(l’) r(p) w(p)

11 7.3 Layered Locking(Cont.)
3-Level 2PL Example Insert Into Persons Values (Name=..., City="Austin", Age=29, ...) Select Name From Persons Where Age=30 Select Name From Persons Where City="Seattle" And Age=29 t1 t2 L2 하나의 sql을 부분적으로 나눠서 진행 insert (CityIndex, insert (AgeIndex, search (AgeIndex, 30) store(x) fetch(z) search (CityIndex, "Seattle") t12 search (AgeIndex, 29) t11 fetch(y) L1 t21 r(p) w(p) r(r) r(n) r(l) w(l) r(r’) r(n’) r(l’) w(l’) r(r’) r(n’) r(l’) r(p) w(p) t111 t112 t113 t121 t122 r(r) r(n) r(l) r(r’) r(n’) r(l’) r(p) w(p) L0 t211 t212 t213

12 7.3 Layered Locking(Cont.)
Selective Layered 2PL We can skip certain layer Li-1 could be Li+1 subtransaction This removes an entire layer connecting the Li-1 nodes in the transaction tree directly to Li+1 subtransaction Advantage We have again a layered schedule with one level less We can apply our standard reasoning for layered schedules Lock acquisition rule: Li operation f(x) with Li-1 ancestor p, which is now a subtransaction, needs to lock x in f mode Lock release rule: Once an Li lock of f(x) with Li-1 ancestor p is released, no other Li descendant of p can acquire any locks. Subtransaction rule: At the termination of an Li operation f(x), all Li+1 locks acquired for descendants of f(x) are released.

13 7.3 Layered Locking(Cont.)
Selective Layered 2PL Example Insert Into Persons Values (Name=..., City="Austin", Age=29, ...) Select Name From Persons Where Age=30 Select Name From Persons Where City="Seattle" And Age=29 L2 insert (CityIndex, insert (AgeIndex, search (AgeIndex, 30) store(x) fetch(z) search (CityIndex, "Seattle") search (AgeIndex, 29) fetch(y) L1 r(p) w(p) r(r) r(n) r(l) w(l) r(r’) r(n’) r(l’) w(l’) r(r’) r(n’) r(l’) r(p) w(p) r(r) r(n) r(l) r(r’) r(n’) r(l’) r(p) w(p) L0

14 7.3 Layered Locking(Cont.)
Layered 2PL with intra-transaction parallelism Delete (City Insert (City Search (City Index,"Austin") fetch(x) Modify(x) L1 Search (City Index,“Boston") fetch(y) L0 r(r) r(n) r(l) r(p) w(p) r(p) w(p) r(r) r(n) r(l) w(l) t11 t12 t13 t14 r(r) r(n) r(l) w(l) t15 r(r) r(n) r(l) t21 r(p) w(p) t22

15 7.4 Locking on General Transaction Forests
Problem Scenario t1 deposit(x) incr(a) append(l) r(p) w(p) r(q) w(q) t2 decr(a) append(l) r(p) w(p) r(q) w(q) deposit(y) incr(b) append(l) r(p) w(p) r(q) w(q) Problem: layers can be “bypassed” Solution: keep locks in “retained” mode

16 7.4 Locking on General Transaction forests
Problem of non layered 2PL schedule The missing layering and the resulting difficult in identifying the appropriate scopes of locking “bypass” the account abstraction and chooses to manipulate the counter and the list directly Low-level operation  High-level operation Inspecting the ancestors Requesting transaction Potentially conflicting the other transactions

17 7.4 Locking on General Transaction Forests(Cont.)
General Object-Model 2PL Lock acquisition rule: Operation f(x) with parent p needs to lock x in f mode Lock conflict rule: A lock requested by r(x) is granted if either no conflicting lock on x is held or when for every transaction that holds a conflicting lock, say h(x), h(x) is a retained lock and r and h have ancestors r‘ and h‘ such that h‘ is terminated and commutes with r‘ Lock release rule: Once a lock of f(x) with parent p is released, no other child of p can acquire any locks. Subtransaction rule: At the termination of f(x), all locks acquired for children of f(x) are converted into retained locks. Transaction rule: At the termination of a transaction, all locks are released.

18 7.4 Locking on General Transaction Forests(Cont.)
Theorem 7.2: The object-model 2PL generates only tree-reducible schedules. t1 t2 h1 f1 h2 f2 ... If all locks of t1 were kept until commit, then tree reducibility were trivially guaranteed. Now show that retained f1 lock by h1 is sufficient to prevent non-commutative subtree: Let f2 be the first conflict with any lock under h1; f2 is allowed to proceed only if h1 is terminated and h2 commutes with h1 isolate h2 from h1 prune h2 and h1 commute h2 with h1 if necessary

19 7.5 Hybrid Algorithms Hybrid algorithms – different protocol used at distinct levels of a layered system Ex) 2PL at the record level & timestamping at the page level 2PL & FOCC 2PL & ROMV Read-only subtransactions are treated particularly favorable and with extremely low overhead

20 7.5 Hybrid Algorithms 2PL & FOCC(forward-oriented optimistic concurrency control) 2PL at level 1 Forward-oriented Optimistic Concurrency Control at level 0 It generates OCSR schedules Theorem 7.3: For 2-level schedules, the combination of 2PL at L1 and FOCC at L0 generates only tree-reducible schedules.

21 7.5 Hybrid Algorithms 2PL & ROMV (read-only multiversion protocol)
2PL at level 1 Multiversion concurrency control protocol at level 0 timestamping for read-only (sub)transactions 2PL for update (sub)transactions Transformation rule 1. isolating record-level operation 2. pruning there subtree 3. applying CSR-style commutativity argument at the record layer Theorem 7.4: For 2-level schedules the combination of 2PL at L1 and ROMV at L0 generates only tree-reducible schedules.

22 7.6 Locking for Return-value Commutativity(Cont.)
Escrow Locking ... on bounded counter object x with lower bound low(x) and upper bound high(x) Approach: maintain infimum inf(x) and supremum sup(x) for the value of x taking into account all possible outcomes of active transactions adjust inf(x) and sup(x) upon operations incr(x), decr(x), and commit or abort of transactions

23 Locking for Return Value commutativity and Escrow Locking
Escrow Locking Example incr(x, ): if x.sup +   x.high then x.sup := x.sup + ; return ok else if x.inf +  > x.high then return no else wait fi fi; decr(x, ): if x.low  x.inf -  then x.inf := x.inf - ; return ok else if x.low > x.sup -  then commit(t): for each op incr(x, ) by t do x.inf := x.inf +  od; for each op decr(x, ) by t do x.sup := x.sup -  od; abort(t): t1 decr(x,75) t2 decr(x,10) t3 incr(x,50) t4 decr(x,20) x(0) = 100 x(4) =55 abort [15, 100] 150] 75] [25, [5, [55, [x.inf, x.sup] constraint: 0  x 23

24 7.6 Locking for Return Value commutativity and Escrow Locking
Escrow Deadlock Example t1 incr(x,10) t2 t3 t4 decr(x,20) x(0) = 0 getval(y) getval(z) update(y) update(z)


Download ppt "Chap.7 Concurrency Control Algorithms on object"

Similar presentations


Ads by Google