Information Technology Reference
In-Depth Information
An S lock is incompatible with an IX lock. Thus, if transaction T 1 holds an
Slockonx, then no other transaction T 2 can simultaneously hold an X lock on
any data item contained in x, because then T 2 would have to hold an IX lock on
x. Accordingly, T 2 is prevented from updating data items contained in a data item
being read by T 1 .
An IS lock and an IX lock are compatible, and so are two IX locks and, naturally,
two IS locks. This is because it is natural to allow both T 1 and T 2 to IS-lock or IX-
lock x with the intention of reading or updating different data items contained in x.
On the other hand, if T 1 and T 2 both hold IX locks on x and want to update the same
data item contained in x, then they would have to hold X locks on that data item,
which is impossible because of the incompatibility of two X locks.
The lock mode SIX is needed for the case that a transaction wants to read all the
data items contained in a larger-granule data item x but to update only some of them.
We want to have a single lock to cover this situation; otherwise the transaction would
have to hold both an S lock and an IX lock on x. Because of the S lock (resp. IX lock)
contained in a SIX lock, a SIX lock is incompatible with an IX lock (resp. an S lock).
The multi-granular locking protocol combined with key-range locking works
as follows. At each level of granularity, key-range locking is used. When a
transaction T explicitly wants to S- or X-lock a data item x with a d -duration lock, it
must first acquire the appropriate d -duration intention locks on every larger-granule
data item on the path from the root of the granule hierarchy down to x. Thus, locks
are acquired first on the larger-granule data items and only then on the contained
smaller-granule ones, according to the granularity hierarchy. Releasing a d -duration
lock on x is possible only if the transaction does not hold any d -duration locks on
data items contained in x. Thus, locks are released in reverse order.
Example 9.1 Assuming a three-level granule hierarchy consisting of a database,
relations, and tuples, the following locks are acquired for the insert action
IŒb;r;x; v by transaction T :
.T; b; IX; commit duration/
.T; .b; r/; IX; commit duration/
.T; .b; r; x/; X; commit duration/
.T; .b; r; y/; X; short duration/
First, the database b is locked with a commit-duration IX lock, then the relation r
contained in b is locked with a commit-duration IX lock, and finally the key x of
the tuple to be inserted into r is locked with a commit-duration X lock and its next
key y with a short-duration X lock.
t
The lock-compatibility matrix for the lock modes specified for multi-granular
locking is shown in Fig. 9.1 . The lock-upgrade matrix is shown in Fig. 9.2 .
The mutual exclusivity order for the lock modes is a partial order, specifically a
lattice with X (the most exclusive lock mode) at the top and IS (the least exclusive
lock mode) at the bottom (Fig. 9.3 ):
IS < IX < SIX < X.
IS < S < SIX < X.
Search WWH ::




Custom Search