Graph-based protocol in database

In two phase protocol there are many problems. This protocol cannot able to handle deadlocks. To solve this problem we use Graph-Based Protocol. This protocol maintains partial ordering of data items. Think that the data item D1, D2................. Dn.  In any transaction at first it accesses D1 before accessing D2 and so on. In this purpose we can say that Graph based protocol consider prior knowledge to lock or unlock data item. There are many Graph based protocol exists but for simplicity I just describe tree protocol. Tree protocol is allowed only exclusive locks. The tree protocol must  maintain the following rules:
1. The first lock may be any data item. Subsequently, a data item Q can be locked by Ti only if the parent of Q is currently locked by Ti.
2. Data item may be unlocked at any time.
3. A data item that has been locked and unlocked by Ti cannot subsequently be relocked by Ti.
To describe this protocol, consider the picture bellow.
And also consider this four transaction. The four transaction given below
1. lock-X(B); lock-X(E); lock-X(D); unlock(B); unlock(E); Lock-X(G); unlock(D); unlock(G).
2. lock-X(D); lock-X(H); unlock(D); unlock(H).
3. lock-X(B); lock-X(E); unlock(E); unlock(B).
4. lock-X(D); lock-X(H); unlock(D); unlock(H).


This four transaction maintains the rules of tree protocol. Consider first transaction:
Based on tree protocol the first lock may be any data item. So in our transaction first lock is lock-X(B) and lock-X(E) is the child of B because the parent B is already locked. unlock(B) and unlock(E) is true becuase the data item may be unlocked at any time and so on.

This protocol ensures freedom from deadlock but not ensure recoverability and cascadelessness.



Comments

Popular posts from this blog

How to construct a B+ tree with example

How to show only month and year fields in android Date-picker?

Visitor Counter Script Using PHP