|
Notes > Database Systems > Locks, 2PL and Deadlocks
|
Locking
A transaction will use a lock to deny data access to other transactions and so prevent incorrect updates. Locks can be Read (shared) or Write (exclusive) locks. Write Locks on a data item prevent other transactions from reading that data item whereas Read Locks simply stop other transactions editing (writing to) the data item.
Two-Phase Locking (2PL)
A transaction follows the 2PL protocol if all lock requests come before the first unlock operation within the transaction. This means there are two main phases within the transaction:
- Growing phase (all locks are acquired) - Shrinking phase (locks released - no new locks can be acquired)
Deadlock
Deadlock occurs when two or more transactions are left waiting for locks held by each other to be released. The only way to break a deadlock is to abort one of the transactions so that a lock is released so that the other transaction can proceed.
The DBMS can manage this process of aborting a transaction when necessary. The aborted transaction is typically restarted so that it is able to execute and commit without the user being aware of any problems occurring.
Search for "Locks, 2PL and Deadlocks" on:
Google |
Kelkoo |
Amazon |
eBay (UK) |
eBay (US)
Search for "Locks, 2PL and Deadlocks" on the rest of Computing Students: Locks, 2PL and Deadlocks
|
|
|