ConcurrencyControl Flashcards
What are the two types of locks in database systems?
Shared (S) lock for reading and Exclusive (X) lock for both reading and writing
What is a Shared (S) lock?
A lock that allows a transaction to read a data item but prohibits any updates
What is an Exclusive (X) lock?
A lock that allows a transaction to both read and write a data item preventing access by other transactions in either mode
What are the two phases in Two-Phase Locking (2PL)?
1) Growing Phase: acquire locks no releases 2) Shrinking Phase: release locks no acquisitions
What is Strict 2PL?
A variant of 2PL where transactions hold all exclusive locks until they commit or abort preventing others from reading uncommitted changes
What is Rigorous 2PL?
A variant of 2PL where transactions hold all locks (both shared and exclusive) until commit or abort
What causes a deadlock in database systems?
When a set of transactions form a cycle of dependencies each waiting for a resource held by another
What are the two main approaches to handle deadlocks?
1) Deadlock Detection using wait-for graphs 2) Deadlock Prevention using timestamp-based ordering
What information does a lock table contain?
Data Item Transaction ID Lock Mode and Queue of Requests
What is the Tree Protocol in graph-based protocols?
A protocol where data items are organized hierarchically first lock can be on any item subsequent locks must follow hierarchy and items can be unlocked anytime but not relocked
What information does Timestamp-Based Protocol maintain for each data item?
R-timestamp (largest timestamp of successful read) and W-timestamp (largest timestamp of successful write)
When is a read operation allowed in Timestamp-Ordering Protocol?
Only if the transaction’s timestamp is greater than or equal to the write timestamp of the data item
When is a write operation allowed in Timestamp-Ordering Protocol?
Only if the transaction’s timestamp is greater than both the read and write timestamps of the data item
What is MVCC (Multiversion Concurrency Control)?
A scheme that maintains multiple versions of each data item to improve concurrency and reduce conflicts
What are the main advantages of MVCC?
1) High concurrency as reads never block writes 2) Reduced likelihood of deadlocks