Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tree Locking Protocol Silberchatz and Kedem, JACM, January1980.

Similar presentations


Presentation on theme: "Tree Locking Protocol Silberchatz and Kedem, JACM, January1980."— Presentation transcript:

1 Tree Locking Protocol Silberchatz and Kedem, JACM, January1980

2 Database Operations  R i (x) – Transaction T i READS data item x.  W i (x) – Transaction T i WRITES data item x.

3 Database Operations - Locks  Transactions may obtain/release locks on data items.  LR i (x) – T i obtains READ LOCK on x.  LW i (x) – T i obtains WRITE LOCK on x.  U i (x) – T i releases LOCK on x.  locked i (x,R): LR i (x) issued but U i (x) not issued yet (T i has READ LOCK on x).  locked i (x,W): LW i (x) issued but U i (x) not issued yet.

4 Basic Rules  A transaction must hold an appropriate lock in order to issue a database operation: –R i (x)  locked i (x,R) –W i (x)  locked i (x,W)  A write lock can not coexist with locks of other transactions:

5 Simplification  We do not distinguish between READ and WRITE operations. READs behave as WRITEs. Both are ACCESS operations.  W and R are replaced by A.  RL and WL are replaced by L.  The rules become: –A i (x)  locked i (x)

6 Notation  Given an execution, we define: –FIRST(A) – First occurrence of operation of type A –LAST(A) – Last occurrence of operation of type A. – - Event B happens after event A.  For a transaction T i we define:  A(T i )={The set of data items accessed by T i }  L(T i )={The set of data items locked by T i }

7 Relation   T i  T j if: –  Observations: –  is irreflexive –  is anti-symmetric

8 Serializability- A Sufficient Condition  An execution T such that: – –  has no cycles. is serializable.  Proof: –Consider the transitive closure  * of  –  * has no cycles –W.l.o.g, let T 1,T 2, … be a possible topologic order. –The serial execution T’ = T 1 T 2 … is equivalent to T.

9 Tree Locking Protocol  The data items have a tree hierarchy.  There is a one-to-one correspondence between the data items and the nodes of a tree.  The protocol: – A i (x)  locked i (x) – – A transaction can not lock a data item previously unlocked by it. –

10 Properties of TLP:  Notation: E(T i ) denotes the first node locked by T i.  Lemma 1: L(T i ) is a connected subgraph of the tree.  Corollary: L(T i ) is a tree, rooted at E(T i ).  Proof (of lemma 1): –Assume by contradiction and there is at least one non-locked node on the path joining them.

11 Properties of TLP (cont’d) –W.l.o.g there is such node between LCA and x. Consider the one which is closest to x and its child (on the path) w. – –T i can not lock LCA(x,y) –T i can not lock y, a contradiction. LCA (x,y) x y

12 Relation   T i  T j if: –  Lemma: –  is anti-symmetric.  Proof: –Assume by contradiction that T 1  T 2, T 2  T 1. –Consider E(T 1 ) and E(T 2 ). One of them is descendent of the other. Otherwise –W.l.o.g assume E(T 2 ) is descendent of E(T 1 ). – Note that:

13  is anti-symmetric  Assume T 1 locked E(T 2 ) before T 2.  T 2  T 1, then :  Let l(x) be the distance of x from E(T 1 ). Consider an x such that l(x) is minimum.  x is not E(T 1 ), otherwise E(T 1 )=E(T 2 ) contradicts our assumption. Therefore, l(x) > 0.  From TLP:  Then:  Consider the time intervals t 1, t 2 in which locked 1 (p(x)) and locked 2 (p(x)) are true.

14  is anti-symmetric  t 1 and t 2 are disjoint.  L i (x) is in t i,,,therefore t 2 precedes t 1.  Implying:  But l(p(x)) < l(x), a contradiction.  Now, assume T 2 locked E(T 2 ) before T 1.  T 1  T 2, then ….

15  is acyclic  Corollary: If T i  T j then:  Lemma:  has no cycles.  Proof:  Assume by contradiction that there are cycles. Choose a cycle of minimum possible length k.  Note that k > 2.  Consider all the nodes E(T i ) for T i in the cycle, there is a partial order on them implied by the tree.  Let v=E(T j ) a minimal element in this partial order.  Both E(T j-1 ) and E(T j+1 ) are v’s ancestors.

16  is acyclic  Consider T j-1  T j  T j+1.  v is in L(T j-1 ), L(T j ) and L(T j+1 ).  Because of the corollary above, they locked it in the order T j-1, T j, T j+1.  Then T j-1 locked v before T j+1 : T j-1  T j+1.  T 1  T 2 … T j-1  T j+1  …  T k is a cycle of length k-1, a contradiction.

17 Serializability under TLP  Theorem: Any execution obeying TLP is rerializable.  Proof: Let T be any execution under TLP. –By definition: –  is acyclic, then  is acyclic. –Part 1 of the sufficient condition is satisfied by by the corollary to the anti-symmetry Lemma. –T is serializable.

18 Deadlock Freedom of TLP  Theorem: Any execution obeying TLP deadlock free.  Proof: Let T be any execution under TLP, and t any time during the execution. –Consider the “waits for” relation  t –If T i  t T j then, there is a data item x, for which locked j (x) and L i (x) is issued (but not granted) as of time t. –Then

19 Deadlock Freedom of TLP –Then T i  T j – –  t is acyclic  T is deadlock free.


Download ppt "Tree Locking Protocol Silberchatz and Kedem, JACM, January1980."

Similar presentations


Ads by Google