Information Technology Reference
In-Depth Information
a pointer to the last lock acquired by T in the list of all locks currently held by T .
This pointer is denoted by
L
AST
-L
OCK
.T /.
A transaction usually holds only one short-duration lock (of a given granularity)
at a time, because it performs only one action at a time. When a transaction run at
the highest isolation level commits, it has usually accumulated as many commit-
duration locks (on data items of a given granularity) as there were different data
items (of that granularity) that the transaction operated on.
6.2
Acquiring and Releasing Locks
For the set of lock modes used in the database management system,
compatibility
is defined as follows. Let m
1
and m
2
be lock modes. Assume that transaction T
2
requests an m
2
-lock on data item x on which another transaction T
1
already
currently holds an m
1
-lock. If the m
2
-lock on x can immediately be granted, we
say that lock mode m
2
is
compatible
with lock mode m
1
.
The compatibility of lock modes is often presented as a
compatibility matrix
.
The compatibility matrix for the set of lock modes
f
S; X
g
is shown in Fig.
6.1
.Lock
mode m
2
is compatible with lock mode m
1
if and only if the the entry for .m
1
;m
2
/
in the lock-compatibility matrix has value true.
A partial order, called
exclusivity order
and denoted by
,isdefinedontheset
of lock modes. For lock modes m
1
and m
2
, m
1
m
2
means that m
2
is at least as
exclusive as m
1
, so that any action permitted by a lock of mode m
1
is also permitted
by a lock of mode m
2
.Fortheset
f
S; X
g
,wehaveS< X, that is, S
XandS
6D
X.
This is because X permits more actions (reading and writing) than S (only reading).
In general, we assume that the set M of lock modes used is a
lattice
so that,
for any m
1
;m
2
2
M , there exists a unique lock mode denoted sup
f
m
1
;m
2
g
(the
supremum
of m
1
and m
2
) that is the least exclusive mode in M that is at least as
exclusive as both m
1
and m
2
.Wehavesup
f
S; X
gD
X.
A
lock upgrade
occurs if a transaction T already holds a d -duration m-mode
lock on a data item x and later requests a d
0
-duration m
0
-lock on x, where either
m<m
0
or no exclusivity order is defined between m and m
0
. If no other transaction
holds on x a lock that is incompatible with m
0
, T is granted on x a d
0
-duration lock
of mode sup
f
m; m
0
g
.
The possible lock upgrades are presented in a
lock-upgrade matrix
.Thelock-
upgrade matrix for the set of lock modes
f
S; X
g
is shown in Fig.
6.2
. A request to
Fig. 6.1
Lock-compatibility
matrix for the set of lock
modes fS; Xg