Presentation is loading. Please wait.

Presentation is loading. Please wait.

18.7 T HE T REE P ROTOCOL CS 257 – D ATABASE S YSTEMS P RINCIPLES Presented by: ASMI SHAH (Class ID: 215)

Similar presentations


Presentation on theme: "18.7 T HE T REE P ROTOCOL CS 257 – D ATABASE S YSTEMS P RINCIPLES Presented by: ASMI SHAH (Class ID: 215)"— Presentation transcript:

1 18.7 T HE T REE P ROTOCOL CS 257 – D ATABASE S YSTEMS P RINCIPLES Presented by: ASMI SHAH (Class ID: 215)

2 O UTLINE : Basics Motivation for Tree based Locking Rules for Access to Tree- Structured Data Why the Tree Protocol works?

3 B ASICS : 18.6 covered the nesting structure of the database elements, with children being subparts of the parent. Here, we have the tree structures formed by the link pattern of the elements themselves. Can manage the locks differently from the 2PL approach.

4 M OTIVATION FOR T REE BASED L OCKING : Locking the node is the right level of lock granularity; As locking smaller pieces is not feasible as gain no benefit, Moreover, treating whole B tree as one database element disturbs the concurrent use of the index. Cannot use 2PL as we need to lock the root node of the B tree, again the root node is not even always affected, so in that case we don’t need to lock the root.

5 R ULES FOR A CCESS TO T REE - S TRUCTURED D ATA : 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 n the node’s parent.

6 W HY THE T REE P ROTOCOL WORKS ? Tree protocol forces a serial order on the transactions involved in a schedule. Order of precedence: Ti <s Tj, if in schedule S, the transactions Ti and Tj lock a node in common, and Ti locks the node first. If 2 transactions lock several elements in common, then they are all locked in the same order.

7 E XAMPLE : Transactions T and U lock 2 or more items in common. X P Z Y T locks First U locks First

8 T HE ORDER OF LOCKING : T locks X first. U locks Y before T. T locks parent P of Z, before U does. T has the lock on P when it locks Z, so U has not locked P when locks Z. Z cannot be the first element that is common between T and U, as they have common ancestor X. U cannot lock Z before having lock on P as it is parent to Z, which is after T locks Z. Thus, T precedes U at every node they lock in common.

9 L ONG S TORY S HORT !! If Ti locks the root before Tj, then Ti locks every node in common with Tj before Tj does. That is Ti <s Tj, but not Tj <s Ti. Which states the Tree Protocol.

10 THANK YOU !!!


Download ppt "18.7 T HE T REE P ROTOCOL CS 257 – D ATABASE S YSTEMS P RINCIPLES Presented by: ASMI SHAH (Class ID: 215)"

Similar presentations


Ads by Google