Graph Based Protocols are yet another way of implementing Lock Based Protocols.
As we know the prime problems with Lock Based Protocol has been avoiding Deadlocks and ensuring a Strict Schedule. We’ve seen that Strict Schedules are possible with following Strict or Rigorous 2-PL. We’ve even seen that Deadlocks can be avoided if we follow Conservative 2-PL but the problem with this protocol is it cannot be used practically. Graph Based Protocols are used as an alternative to 2-PL. Tree Based Protocols is a simple implementation of Graph Based Protocol.
A prerequisite of this protocol is that we know the order to access a Database Item. For this we implement a Partial Ordering on a set of the Database Items (D) {d1, d2, d3, ….., dn} . The protocol following the implementation of Partial Ordering is stated as-
- If di –> dj then any transaction accessing both di and dj must access di before accessing dj.
- Implies that the set D may now be viewed as a directed acyclic graph (DAG), called a database graph.
Tree Based Protocol –
- Partial Order on Database items determines a tree like structure.
- Only Exclusive Locks are allowed.
- The first lock by Ti may be on any data item. Subsequently, a data Q can be locked by Ti only if the parent of Q is currently locked by Ti.
- Data items can be unlocked at any time.
Following the Tree based Protocol ensures Conflict Serializablity and Deadlock Free schedule. We need not wait for unlocking a Data item as we did in 2-PL protocol, thus increasing the concurrency.
Now, let us see an Example, following is a Database Graph which will be used as a reference for locking the items subsequently.

Image – Database Graph
Let’s look at an example based on the above Database Graph. We have three Transactions in this schedule and this is a skeleton example, i.e, we will only see how Locking and Unlocking works, let’s keep this simple and not make this complex by adding operations on data.
| T1 | T2 | T3 | |
|---|---|---|---|
| 1 | Lock-X(A) | ||
| 2 | Lock-X(B) | ||
| 3 | Lock-X(D) | ||
| 4 | Lock-X(H) | ||
| 5 | Unlock-X(D) | ||
| 6 | Lock-X(E) | ||
| 7 | Lock-X(D) | ||
| 8 | Unlock-X(B) | ||
| 9 | Unlock-X(E) | ||
| 10 | Lock-X(B) | ||
| 11 | Lock-X(E) | ||
| 12 | Unlock-X(H) | ||
| 13 | Lock-X(B) | ||
| 14 | Lock-X(G) | ||
| 15 | Unlock-X(D) | ||
| 16 | Unlock-X(E) | ||
| 17 | Unlock-X(B) | ||
| 18 | Unlock-X(G) |
From the above example, first see that the schedule is Conflict Serializable. Serializablity for Locks can be written as T2 –> T1 –> T3.
Data items Locked and Unlocked are following the same rule as given above and follows the Database Graph.
Thus, let’s revise once more what are the key points of Graph Based Protocols.
Advantage –
- Ensures Conflict Serializable Schedule.
- Ensures Deadlock Free Schedule
- Unlocking can be done anytime
With some advantages comes some Disadvantages also.
Disadvantage –
- Unnecessary locking overheads may happen sometimes, like if we want both D and E, then at least we have to lock B to follow the protocol.
- Cascading Rollbacks is still a problem. We don’t follow a rule of when Unlock operation may occur so this problem persists for this protocol.
- Lock Based Concurrency Control Protocol in DBMS
- Two Phase Locking (2-PL) Concurrency Control Protocol | Set 3
- Timestamp based Concurrency Control
- Concurrency Control in DBMS
- Validation Based Protocol in DBMS
- Concurrency Control Techniques
- Concurrency problems in DBMS Transactions
- Difference between Stop and Wait protocol and Sliding Window protocol
- Real-time Transport Control Protocol (RTCP)
- Difference between Flow Control and Congestion Control
- Difference between Flow Control and Error Control
- Main difference between Timestamp protocol and Thomos write rule in DBMS
- Process-based and Thread-based Multitasking
- Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
- Difference between Memory based and Register based Addressing Modes
- Log based Recovery in DBMS
- Types of Schedules based Recoverability in DBMS
- Concurrency in Operating System
- Precedence Graph For Testing Conflict Serializability in DBMS
- Regular Graph in Graph Theory
Overall this protocol is mostly known and used for its unique way of implementing Deadlock Freedom.
References: Database System Concepts, Fifth Edition [Silberschatz, Korth, Sudarshan], Chapter-16.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : bikashdutta

