Class-L40
Class-L40
12/9/2009 4
Compatibility Matrix with
Intention Lock Modes
The compatibility matrix for all lock modes is:
IS IX S S IX X
IS ×
IX × × ×
S × × ×
S IX × × × ×
X × × × × ×
12/9/2009 5
Multiple Granularity Locking
Scheme
Transaction Ti can lock a node Q, using the following
rules:
1. The lock compatibility matrix must be observed.
2. The root of the tree must be locked first, and may be
locked in any mode.
3. A node Q can be locked by Ti in S or IS mode only
if the parent of Q is currently locked by Ti in either
IX or IS mode.
4. A node Q can be locked by Ti in X, SIX, or IX mode
only if the parent of Q is currently locked by Ti in
either IX or SIX mode.
12/9/2009 6
5. Ti can lock a node only if it has not
previously unlocked any node (that is, Ti
is two-phase).
6. Ti can unlock a node Q only if none of
the children of Q are currently locked by
Ti.
Observe that locks are acquired in root-
to-leaf order,
whereas they are released in leaf-to-root
order.
12/9/2009 7
Deadlock Handling
lock-X on X
write (X)
lock-X on Y
write (X)
wait for lock-X on X
wait for lock-X on Y
12/9/2009 8
Deadlock Handling
12/9/2009 13
Deadlock Recovery
When deadlock is detected :
Some transaction will have to rolled back (made a
victim) to break deadlock. Select that transaction as
victim that will incur minimum cost.
Rollback -- determine how far to roll back transaction
12/9/2009 14
12/9/2009 15