Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Graph Based Concurrency Control Protocol in DBMS
Next article icon

Graph Based Concurrency Control Protocol in DBMS

Last Updated : 05 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In a Database Management System (DBMS), multiple transactions often run at the same time, which can lead to conflicts when they access the same data. Graph-Based Concurrency Control Protocol helps manage these conflicts and ensures that the database remains consistent.

  • In this protocol, transactions are represented as nodes in a graph, and conflicts between them are shown as edges.
  • Before granting a lock on a data item, the system checks for cycles in the graph. If a cycle is detected, one of the transactions is rolled back to prevent deadlock and ensure smooth execution.
  • A Graph-Based Protocol is a way of implementing Lock Based Protocols.  It is deadlock free, but no guarantee of recoverability.

This method is more powerful than traditional locking techniques, as it can handle complex dependencies between transactions. However, it can be computationally expensive for large databases.

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 Protocols is a simple implementation of Graph Based Protocol. 

Tree Based Protocol

The Tree Protocol is a graph-based concurrency control method that ensures conflict serializability and deadlock freedom. Unlike Two-Phase Locking (2PL), it follows a hierarchical structure for locking data items.

Rules of Tree Protocol

  1. Only exclusive (X) locks are allowed – No shared (S) locks are used.
  2. The first lock can be on any data item – After that, a transaction can lock a data item only if it has locked its parent first.
  3. Data items can be unlocked at any time – There is no strict two-phase rule.
  4. No relocking – Once a transaction unlocks a data item, it cannot lock it again.

The Tree Protocol offers a balance between concurrency and deadlock prevention, making it useful in certain database applications.

222

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 work, let's keep this simple and not make this complex by adding operations on data.

 T1T2T3
1Lock-X(A)  
2Lock-X(B)  
3 Lock-X(D) 
4 Lock-X(H) 
5 Unlock-X(D) 
6Lock-X(E)  
7Lock-X(D)  
8Unlock-X(B)  
9Unlock-X(E)  
10  Lock-X(B)
11  Lock-X(E)
12 Unlock-X(H) 
13Lock-X(B)  
14Lock-X(G)  
15Unlock-X(D)  
16  Unlock-X(E)
17  Unlock-X(B)
18Unlock-X(G)  

From the above example, first see that the schedule is Conflict Serializable. Serializability for Locks can be written as T2 --> T1 --> T3. 
Data items Locked and Unlocked are following the same rule as given above and follow the Database Graph. 

Advantages of Tree Protocol                                 

  • Deadlock-free – No cycles form in the lock order, so no rollbacks are needed.
  • Increased concurrency – Unlocking can happen earlier than in Two-Phase Locking, reducing wait times.
  • Allows different schedules – Some schedules that are not possible under 2PL can be executed under the tree protocol.

Drawbacks of Tree Protocol

  • No guarantee of recoverability – Can lead to cascading rollbacks if not handled properly.
  • Extra locks required – Transactions may need to lock unnecessary data items, increasing waiting time and locking overhead.
  • Some schedules allowed in 2PL are not possible in Tree Protocol – While it provides flexibility, it also has limitations.

FAQs on Graph-Based Concurrency Control Protocol in DBMS

What is Graph-Based Concurrency Control in DBMS?

Graph-Based Concurrency Control is a method that represents transactions as nodes in a directed graph, with edges showing conflicts when transactions access the same data. It ensures consistency by detecting cycles and resolving conflicts.

How does the Graph-Based Concurrency Control Protocol prevent deadlocks?

It prevents deadlocks by ensuring that transactions follow a predefined partial order when accessing data items, forming a Directed Acyclic Graph (DAG). If a cycle is detected, a transaction is rolled back to maintain serializability.

What is the role of partial ordering in Graph-Based Concurrency Control?

A partial order is imposed on data items, meaning if a transaction accesses a set of items, it must access them in a specific order. This ensures a structured execution pattern and prevents cyclic dependencies.

How does the Tree Protocol relate to Graph-Based Concurrency Control?

The Tree Protocol is a type of graph-based concurrency control where transactions acquire exclusive locks following a hierarchical structure. This prevents deadlocks but may require transactions to lock unused data, increasing overhead.

What are the advantages and limitations of Graph-Based Concurrency Control?

It efficiently manages complex dependencies and eliminates deadlocks but can be computationally expensive and less scalable for large databases with many concurrent transactions. The need for predefined ordering can also reduce flexibility.


Next Article
Graph Based Concurrency Control Protocol in DBMS

Z

zerocool
Improve
Article Tags :
  • Misc
  • DBMS
  • GATE CS
Practice Tags :
  • Misc

Similar Reads

    Lock Based Concurrency Control Protocol in DBMS
    In a DBMS, lock-based concurrency control is a method used to manage how multiple transactions access the same data. This protocol ensures data consistency and integrity when multiple users interact with the database simultaneously.This method uses locks to manage access to data, ensuring transactio
    7 min read
    Concurrency Control in DBMS
    In a database management system (DBMS), allowing transactions to run concurrently has significant advantages, such as better system resource utilization and higher throughput. However, it is crucial that these transactions do not conflict with each other. The ultimate goal is to ensure that the data
    7 min read
    Timestamp based Concurrency Control
    Timestamp-based concurrency control is a method used in database systems to ensure that transactions are executed safely and consistently without conflicts, even when multiple transactions are being processed simultaneously. This approach relies on timestamps to manage and coordinate the execution o
    5 min read
    MOSS Concurrency Control Protocol (Distributed Locking in Database)
    This is a protocol which is used to control the concurrency in the Distributed database environment, Here we'll read about the rules and regulations that are required to keep in mind while applying MOSS Concurrency Control Protocol. MOSS Concurrency Control Protocol:- a) It is mainly used for handli
    2 min read
    Types of Locks in Concurrency Control
    Commercial demands for ensuring smooth functionality and highly efficient run-time servers, make it highly prime for Database Designers to work out systems and code which cleverly avoid any kinds of inconsistencies in multi-user transactions, if not doubt the standard of memory management in read-he
    11 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences