Discuss different methods for concurrency control Flashcards
- what is a locking method.
is placing locks on database objects (e.g. rows, tables) to prevent concurrent transactions from accessing or modifying the same data simultaneously.
Lock granularity (level or lock use). - Database-Level lock
- Database-level: restricts access to the owner of the lock and allows only one user at a time to access the database.
Lock granularity (level or lock use). - Table-Level lock
- Table-level: allows only one transaction at a time to access a table.
- Page-level: an entire diskpage or section of a disk is locked.
- Row-level: concurrent transaction
Lock granularity (level or lock use). - Page-Level lock
- Page-level: an entire diskpage or section of a disk is locked.
Lock granularity (level or lock use). - Row-Level lock
- Row-level: concurrent transactions to access the same rows of the same table, even if the rows are on the same page.
Lock granularity (level or lock use). - Field-Level lock
- Field-level: allows concurrent transactions to access the same rows as they require the use of different attributes within that row.
Lock types - Binary Lock.
- Binary lock - has only two states, locked (1) and unlocked (0). if a data item is locked, no other transaction can use that data item.
Lock types - Exclusive lock.
Issued when a transactions must update or (WRITE) a data item, an exclusive lock is requested, its application for a lock will not proceed until all locks are released.
Lock types - Shared lock.
multiple processes can simultaneously hold shared locks to enable them to read without updating.
what is a deadlock
occurs when two transactions wait indefinitely for each other to unlock data.
Deadlock Control Techniques. - Avoidance
Avoidance - transaction must obtain all the locks needed before it can be executed.
Deadlock Control Techniques. - Prevention
Prevention - transaction requesting a new lock is aborted when there is a possibility that a deadlock can occur.
Deadlock Control Techniques. - Detection
Detection - DBMS tests database periodically for deadblocks, if found, victim transaction is aborted.
what is two-phase locking.
2PL - A set of rules that manage how transactions acquire and release locks to ensure serializability, though it doesnt prevent deadlocks.
2PL - Growing Phase.
The transaction acquires all the locks it needs without releasing any.