What is a lock ?
A transaction can acquire a lock on a data item prior to accessing that item.
This guarantees exclusive use of that item, and the lock is released when the transaction is complete.
What is the point of a lock ?
Locks prevent other transactions from reading inconsistent data, as this cannot be guaranteed during a transaction.
Who manages locking procedures ?
DMBS lock manager initiates and enforces the procedures.
At which levels can lock granularity take place?
Database, table, page, row, attribute
What are the two lock types?
What are the two main locking issues ?
Locks prevent data inconsistencies but can cause transactions to be:
What can be used to solve locking issues ?
Two Phase Locking Protocol (2PL).
It uses a ‘growing phase’ to acquire all the locks w/o unlocking any that time, and then conversely uses a ‘shrinking time’ to release them without locking anything else in the meantime.
What are deadlocks ?
T1 accesses items X and Y whilst T2 accesses items Y and X and neither has unlocked each others’ required item.
May happen if one of the transactions wants an exclusive lock on an item.
Does not occur amongst shared locks.
What are the 3 ways to control deadlocks ?
Can deadlock occur when a transaction requests a shared lock on an item?
No – deadlock occurs on exclusive lock issues.
Which of the following can be used for deadlock detection?
I. Timeout II. Precedence Graph III. 2PL Protocol IV. Wait-For Graph V. Rolling back a transaction
I. Timeout
and
IV. Wait-For Graph