💾
Welcome to DataGenesis !
  • 🚀 Welcome to the Database Management System Playground! 📊💾
  • Basics of DBMS
    • Database Management System
    • DBMS V/S File System
    • DBMS Architectures
    • Tier 3 Architecture / Three Schema Architecture
  • E-R Data Model
    • Basics of E-R Model
    • Attributes in E-R Model
    • Null Values
    • Strong & Weak Entities
    • Relationship Constraints
    • Recursive Relationships
    • E-R Diagrams
    • Extended E-R Model
  • Relational Model
    • Relational Model
    • Facts About Relational Model
    • Types of Keys in Relational Model
    • Integrity Constraints
    • Anomalies in Relational Model
  • Transform - ER Model to Relational Model
    • Mapping from ER Model to Relational Model
  • SQL - Structured Query Language
    • SQL
    • CRUD Operations
    • Data Types
    • Type of Commands in SQL
    • Working With Commands
    • Data Retrieval Commands
  • Normalisation
    • Functional Dependencies
    • Armstrong's Axioms
    • Multivalued Dependency
    • 1 Normal Form
    • 2 Normal Form
    • 3 Normal Form
    • Boyce-Codd Normal Form (BCNF)
    • 4 Normal Form
    • 5 Normal Form
    • Lossless Decomposition, Lossless Join ,and Dependency Preserving Decomposition, Denormalization
  • Concurrency Control
    • Transactions & Concurrency
    • Scheduling of Transactions
    • Problems & Strategies in Concurrency Control
    • Transaction & ACID Properties
    • How to implement ACID Properties
    • Atomicity Techniques
    • Durability Techniques
    • Implementing Locking in DBMS
    • Concurrency Control Protocols
      • Two Phase Locking
      • Timestamp Ordering
      • Multi Version Concurrency Control Techniques
    • Starvation in DBMS
    • Deadlock in DBMS
    • Log Based Recovery
  • NoSQL & Types of Databases
    • SQL V/S NoSQL
    • Types of Databases
  • DB Optimization
    • File Organization
      • Hash File Organizations
      • B+ Tree File Organization: A Guide to Efficient Data Indexing
      • Cluster File Organization
    • Indexing in DBMS
      • Primary Indexing
      • Clustered Indexing
      • Secondary Indexing
      • Multilevel Indexing
  • Distributed Databases
    • Database Clustering
    • Partitioning and Sharding
    • CAP Theorm
Powered by GitBook
On this page
  • Understanding Multiversion Concurrency Control
  • Storage Overhead Considerations
  • Timestamp-Based Multiversion Technique
  • Enforcing Serializability
  • Certify Locks
  • Lock Compatibility

Was this helpful?

  1. Concurrency Control
  2. Concurrency Control Protocols

Multi Version Concurrency Control Techniques

Concurrency control is a critical aspect of database management systems to ensure that multiple transactions can access and modify data without leading to inconsistencies. Traditionally, techniques like Two-Phase Locking (2PL) and Timestamp Ordering (TO) have been used to maintain data consistency. However, in scenarios where preserving older versions of data is essential for historical tracking or other purposes, Multiversion Concurrency Control techniques come into play.

Understanding Multiversion Concurrency Control

Multiversion Concurrency Control (MVCC) techniques allow databases to maintain multiple versions or values of the same data item. This means that when a transaction updates a data item, the old value is retained, and the new value is stored as a new version. MVCC techniques aim to ensure the serializability of transactions while allowing for scenarios where reading older data versions is necessary.

Storage Overhead Considerations

One of the primary concerns with MVCC is the increased storage requirements. Storing multiple versions of data items consumes more disk space. However, there are scenarios where this storage overhead is justified. For instance, in systems requiring data recovery capabilities or those dealing with temporal databases (tracking changes and their timestamps), maintaining older versions is essential. In such cases, the additional storage cost is often acceptable.

Timestamp-Based Multiversion Technique

One widely used MVCC technique is based on timestamps. In this method, several versions (X1, X2, ..., Xk) of each data item X are maintained. For each version, the system keeps track of two timestamps:

  1. read_TS(Xi): The read timestamp of version Xi, indicating the highest timestamp of transactions that have successfully read this version.

  2. write_TS(Xi): The write timestamp of version Xi, indicating the timestamp of the transaction that wrote this version.

When a transaction T writes a new version of X, both read_TS(Xk+1) and write_TS(Xk+1) are set to TS(T), creating a new version Xk+1.

Enforcing Serializability

To maintain serializability, specific rules are enforced:

  1. For Write Operations (write_item(X)):

    • If read_TS(Xi) > TS(T) and write_TS(Xi) <= TS(T) for a version Xi, the transaction T is aborted and rolled back.

    • Otherwise, a new version Xj is created with read_TS(Xj) = write_TS(Xj) = TS(T).

  2. For Read Operations (read_item(X)):

    • The system identifies the version Xi with the highest write_TS(Xi) that is less than or equal to TS(T).

    • The value of Xi is returned to the transaction T, and read_TS(Xi) is updated if necessary.

Certify Locks

Multiversion 2PL introduces three locking modes: read, write, and certify. This approach allows concurrent reads while a transaction holds a write lock. However, before committing, a transaction must obtain certify locks on all items for which it holds write locks. This ensures data consistency and avoids conflicts.

Lock Compatibility

The lock compatibility table for multiversion 2PL permits concurrent reads and single writes. Still, it mandates exclusive certify locks before committing. While this approach prevents cascading aborts (a transaction abort causing subsequent transactions to abort), it may lead to deadlocks if read locks are upgraded to write locks. Deadlock handling mechanisms must be in place to address such situations.

Conclusion

Multiversion Concurrency Control techniques provide a flexible solution for managing concurrency in database systems. They enable the preservation of historical data versions, support concurrent read operations during write operations, and ensure data consistency. However, these benefits come with the trade-off of increased storage overhead and the need to manage additional locking modes. Understanding the specific requirements of your database system is crucial in deciding whether to adopt MVCC techniques.

PreviousTimestamp OrderingNextStarvation in DBMS

Last updated 1 year ago

Was this helpful?