• Home
  • Concurrency Control

    Concurrency control in Relational Database Management Systems (RDBMS) is a mechanism that ensures the proper handling of concurrent transactions executing simultaneously. It prevents conflicts and maintains data consistency when multiple users or applications access and modify the same data concurrently. Concurrency control techniques enable efficient and safe execution of transactions in a multi-user environment. Here are some commonly used concurrency control techniques:


    1. Locking:

    Locking is a widely used concurrency control mechanism. It involves acquiring and releasing locks on data items to prevent conflicting access. Two commonly used lock types are:

    - Shared Lock (Read Lock): Allows multiple transactions to read the data simultaneously but prevents write operations by other transactions.
    - Exclusive Lock (Write Lock): Allows a transaction exclusive access for both read and write operations, preventing other transactions from accessing the data.

    Locks are acquired before accessing a data item and released when the transaction completes. Locking ensures serializability by enforcing a strict order of operations and preventing conflicting operations on the same data.


    2. Two-Phase Locking (2PL):

    Two-Phase Locking is a concurrency control protocol that follows a two-step process: the growing phase and the shrinking phase. In the growing phase, transactions acquire locks and do not release any locks. In the shrinking phase, transactions release locks and do not acquire any new locks. This protocol ensures that transactions do not conflict with each other and that no new conflicts are introduced after a lock is released. Two-Phase Locking ensures serializability and prevents phenomena such as dirty reads, non-repeatable reads, and write skew.


    3. Multiversion Concurrency Control (MVCC):

    MVCC is a technique that allows multiple versions of a data item to exist concurrently. When a transaction modifies a data item, a new version is created instead of overwriting the existing version. Each version of the data item is associated with a timestamp representing its validity. Transactions read the version of data that is consistent with their snapshot timestamp, ensuring read consistency and eliminating the need for locks. MVCC improves concurrency by allowing simultaneous reads and writes on different versions of the data.


    4. Timestamp Ordering:

    Timestamp ordering assigns a unique timestamp to each transaction based on their start time or arrival order. Transactions are ordered based on their timestamps, and conflicts are resolved by comparing timestamps. The older transaction is given priority over the newer transaction. This technique ensures that the order of operations follows the timestamp order, guaranteeing serializability and preventing conflicts.


    5. Optimistic Concurrency Control (OCC):

    OCC assumes that conflicts between transactions are rare. It allows transactions to proceed without acquiring locks but checks for conflicts during the commit phase. Transactions execute and make changes to data without blocking other transactions. During commit, conflicts are detected by comparing the read and write sets of transactions. If conflicts are detected, the transaction is rolled back and re-executed. OCC reduces the overhead of acquiring and releasing locks but requires extra effort to handle conflicts during commit.


    These are some of the common concurrency control techniques used in RDBMS to manage concurrent transactions and ensure data consistency. The choice of concurrency control technique depends on factors such as the expected workload, data access patterns, and system requirements.



    About the Author



    Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

    We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





     PreviousNext