We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23
Q1.
Basic 2pl or(Basictwophaselocking)
Basic two-phase locking (2PL) is a concurrency control mechanism
used in database management systems to ensure serializability of transactions. It consists of two phases: the growing phase and the shrinking phase. CONT…
1. Growing phase 2. Shrinking Phase
During the growing phase, a In the shrinking phase, a transaction can acquire locks on transaction can release locks but data items but cannot release any cannot acquire any new locks. locks. After a transaction has finished When a transaction needs to accessing all the data items it read or write a data item, it first needs, it can release the locks it acquires a shared (read) lock or holds. an exclusive (write) lock on that data item, respectively 2. Conserative 2vpl Conservative two-phase locking (C2PL) is a concurrency control protocol that falls under the category of pessimistic concurrency control mechanisms. C2PL is designed to address some of the limitations and drawbacks of strict two-phase locking (strict 2PL) by adopting a more conservative approach to lock management. Key features of conservative 2PL 1. Lock Acquisition at Transaction Start: 2. No lock release until commit: In C2PL, transactions acquire all the Similar to Strict 2PL, transactions in locks they will need for their entire C2PL hold onto all acquired locks until execution at the beginning of the they reach the commit point. transaction. This differs from Strict 2PL, where locks are acquired and released Transactions do not release any locks dynamically during transaction prematurely, ensuring that changes execution. made by a transaction are not visible to other transactions until the transaction commits. 3.Strict 2pl Strict two-phase locking (strict 2PL) is an extension of the basic two phase locking (2PL) protocol with additional restrictions to ensure strictness in transaction execution. Strict 2PL aims to prevent cascading aborts and guarantee strict serializability of transactions CONT… Benefits of strict 2PL Limitations of strict2PL Prevents cascading aborts: By Performance overhead: The strictness of holding locks until the commit point, lock management in Strict 2PL can lead Strict 2PL prevents cascading aborts to increased contention and potential and maintains data consistency. performance degradation in high- concurrency environments. Ensures strict serializability: Transactions in a system using Strict - Deadlock risk: The risk of deadlocks 2PL are guaranteed to execute in a still exists in Strict 2PL, especially in strict serializable order, preserving the scenarios where transactions acquire integrity of the database. locks in conflicting orders. 4 .Rigorous 2pl: Rigorous Two-Phase Locking (Rigorous 2PL) is a concurrency control protocol that builds upon the principles of Strict Two-Phase Locking (Strict 2PL) to provide a more robust and rigorous approach to lock management in database systems.
Rigorous 2PL is designed to address some of the limitations of Strict
2PL and enhance data consistency and transaction isolation guarantees. Key features of Rigorous 2PL include 1.Strict lockingprotocol 2. Two phase lockin 3. Lock release at commit Rigorous 2PL enforces Similar to Strict 2PL, In Rigorous 2PL, a strict locking protocol Rigorous 2PL follows the locks are released only where transactions must two-phase locking at the commit point of acquire all the required protocol where locks before accessing transactions acquire all a transaction any data item necessary locks in a growing phase and release them in a shrinking phase. 2. Granularity of data items and multiple granularity locking
Granularity of data items Multiple granularity locking(m)
refers to the level at which locks are Is a technique that allows different applied within a database system. The levels of granularity for locks within a granularity of locks can vary from database system. coarse-grained (large units of data) to In mgl, locks can be applied at various fine-grained (smaller units of data). levels of granularity, such as table-level Different levels of granularity locks, page-level locks, or row-level impact concurrency, performance, and locks, depending on the specific data scalability in a database system access requirements of transactions. Q3. Using locks for concurency control in indexes
Locks can be used for concurrency control in indexes to ensure that
multiple transactions can access and modify index data concurrently without causing conflicts or inconsistencies. When multiple transactions are accessing the same index concurrently, locks are used to prevent data corruption and maintain the integrity of the index. There are several ways locks can be used for concurrency control in indexes 1. Shared locks (s-locks): 2. Exclusive locks (x-locks): Shared locks allow multiple Exclusive locks prevent other transactions to read data from an index transactions from reading or writing to simultaneously. When a transaction an index while the locking transaction is holds a shared lock on an index, other making changes. transactions can also acquire shared Exclusive locks are used when a locks on the same index. transaction needs to modify the index Shared locks are compatible with other data and wants to ensure that no other shared locks but incompatible with transactions can access the index until exclusive locks. the modification is complete. CONT…
3. Intent locks 4. Update locks
Intent locks indicate that a Update locks are a combination of transaction intends to acquire a shared and exclusive locks used to specific type of lock (shared or prevent deadlocks in certain scenarios. exclusive) on an index or its associated Update locks are acquired before data. converting a shared lock to an exclusive Intent locks are used to prevent lock and help avoid conflicts with other conflicting lock modes at higher or transactions attempting to acquire lower levels of granularity. exclusive locks on the same data. Q4.Other concurrency control issues Concurrency control: in database systems involves managing access to shared resources to ensure data consistency and prevent conflicts among concurrent transactions. In addition to multiple granularity locking, there are other concurrency control issues such as insertion, deletion, phantom records, interactive transactions, and the use of latches. CONT… 1. Insertion and deletion: 2. Phantom records: Insertion and deletion operations can Phantom records refer to the phenomenon introduce concurrency control where a transaction sees additional records challenges in databases. When that were not present when the transaction multiple transactions are concurrently started. This can occur when a transaction inserting or deleting records in a reads a range of records multiple times, table, conflicts may arise if proper and other transactions insert new records locking mechanisms are not in place. within that range. To prevent phantom It is essential to use appropriate locks records, isolation levels such as to prevent data inconsistencies and Serializable or Repeatable Read can be maintain the integrity of the database used to ensure consistent query results. CONT… 3. Interactive transactions: 4. Latches: Interactive transactions: Latches: are low-level synchronization involve user interactions with the mechanisms used in database systems to database system, where users input protect critical data structures such as commands or queries that need to be buffer pools, index structures, and control processed concurrently with other blocks. Latches are lightweight and transactions. Managing interactive provide short-term protection for data transactions requires efficient structures during read and write handling of user input, query operations. Unlike locks, latches are processing, and response times to typically held for a short duration and do maintain responsiveness and data not support deadlock detection or consistency. transaction management When are latches used? Latches are used in scenarios where fine-grained synchronization is required to ensure data structure integrity without the overhead of full-fledged locks. Common use cases for latches include:- Buffer management: latches are used to protect buffer pool structures during read and write operations to ensure data consistency and prevent corruption. Index maintenance: latches are employed to protect index structures when performing insertions, deletions, or updates to maintain index integrity. Control block access: latches are used to serialize access to control blocks or metadata structures to prevent concurrent modifications that could lead to inconsistencies. Discuss two multiversion techniques concurency control
Multiversion concurrency control (MVCC) is a technique used in database systems
to manage concurrent access to data by creating multiple versions of a data item. This allows transactions to read consistent snapshots of the database without being blocked by other transactions performing write operations. Two common multiversion techniques for concurrency control are snapshot isolation and serializable snapshot isolation. CONT…
1. Snapshot isolation: is a multiversion concurrency control technique that
allows transactions to read a consistent snapshot of the database at the beginning of the transaction. 2. Serializable snapshot isolation (SSI): is an extension of snapshot isolation that guarantees serializability, which ensures that the execution of concurrent transactions is equivalent to some serial order of execution. Q5.what is certify lock? A certify lock is a concurrency control mechanism used in database systems to enforce serializability and prevent conflicts between transactions. It is a type of lock that is acquired by a transaction to certify that it can commit its changes without violating serializability constraints. Certify locks are commonly used in serializable snapshot isolation (ssi) concurrency control techniques to enforce strict serializability and prevent anomalies such as non- repeatable reads, write skew, and lost updates. By acquiring certify locks and performing validation checks, transactions can ensure that their changes are consistent with the overall state of the database and maintain data integrity in a concurrent environment. Q6,What are the advantage and disadvantage of using certify locks? Advantages of using certify locks: 1.Enforce serializability: certify locks help ensure that transactions maintain serializability, which is a key property in database systems to prevent conflicts and anomalies. 2. Data integrity: by acquiring certify locks and validating changes before committing, transactions can maintain data integrity and consistency in the database. 3. Reduced conflicts: certify locks help reduce conflicts between transactions by signaling their intention to commit changes and preventing interference from other transactions. 4. Concurrency control: certify locks are effective in managing concurrency and coordinating transactions to prevent issues such as non-repeatable reads and write skew. Q6.what are the advantage and disadvantage of using certify locks? Advantages of using certify locks: 1.Enforce serializability: certify locks help ensure that transactions maintain serializability, which is a key property in database systems to prevent conflicts and anomalies. 2. Data integrity: by acquiring certify locks and validating changes before committing, transactions can maintain data integrity and consistency in the database. 3. Reduced conflicts: certify locks help reduce conflicts between transactions by signaling their intention to commit changes and preventing interference from other transactions. 4. Concurrency control: certify locks are effective in managing concurrency and coordinating transactions to prevent issues such as non-repeatable reads and write skew. CONT… Disadvantages of using certify locks: 1. Overhead: acquiring and releasing certify locks incurs overhead in terms of processing time and resources, which can impact the performance of the database system, especially in high-concurrency canenvironments. 2. Deadlocks: the use of certify locks increase the likelihood of deadlocks occurring when transactions wait for each other to release their locks, leading to potential performance issues and delays. 3. Complexity: implementing certify locks and ensuring proper validation checks require additional complexity in the database system, which can make it more challenging to manage and maintain. 4. Limited scalability: in large-scale systems with a high volume of transactions, the use of certify locks may introduce scalability limitations due to increased contention and coordination overhead. Thank you a lot ! Have you a question?