Presentation is loading. Please wait.

Presentation is loading. Please wait.

18.7 The Tree Protocol Andy Yang. Outline Introduction Motivation Rules for Access to Tree-Structured Data Why the Tree Protocol Works.

Similar presentations


Presentation on theme: "18.7 The Tree Protocol Andy Yang. Outline Introduction Motivation Rules for Access to Tree-Structured Data Why the Tree Protocol Works."— Presentation transcript:

1 18.7 The Tree Protocol Andy Yang

2 Outline Introduction Motivation Rules for Access to Tree-Structured Data Why the Tree Protocol Works

3 Introduction In previous section we dealt with trees that are formed by the nesting structure. – Children being subparts of the parent In this section, we deal with tree structures that are formed by the link pattern. – Database elements are disjoint pieces of data – B-trees are an important example

4 Motivation If we use a standard set of lock modes (shared, update and exclusive) and two phase locking, then concurrent use of the B- tree is almost impossible. Any transaction that inserts or deletes could wind up rewriting the root of the B-tree.  Only one transaction that is not read-only can access the B-tree at any time.

5 Motivation However, in most situations a B-tree node will not be rewritten, even if the transaction inserts or deletes a tuple. Thus, as soon as a transaction moves to a child of the root and observes the situation that rules out a rewrite of the root, we would like to release the lock on the root.

6 Motivation Releasing the lock on the root early will violate two phase locking, so we cannot be sure that the schedule of several transactions accessing the B-tree will be serializable. The solution is a specialized protocol for transactions that access tree structured data like B-trees.

7 Rules for Access to Tree-Structured Data We assume that there is only one kind of lock, represented by lock requests of the form l i (x). 1. A transaction’s first lock may be at any node of the tree. 2. Subsequent locks may only be acquired if the transaction currently has a lock on the parent node. 3. Nodes may be unlocked at any time. 4. A transaction may not relock a node on which it has released a lock, even if it still holds a lock on the node’s parent.

8 Example

9

10 Why the Tree Protocol Works The precedence graph If the precedence graph has no cycles, then we claim that any topological order of the transactions is an equivalent serial schedule.

11 Observations: – If two transactions lock several elements in common, then they are all locked in the same order. – If Ti locks the root before Tj, then Ti locks every node in comon with Tj before Tj does.


Download ppt "18.7 The Tree Protocol Andy Yang. Outline Introduction Motivation Rules for Access to Tree-Structured Data Why the Tree Protocol Works."

Similar presentations


Ads by Google