Information Technology Reference
In-Depth Information
the operation, but the short-duration X lock on the next key can be acquired only
after the page that covers key x has been fixed and write-latched and the key next to
it (which may or may not reside on the same page) has been found.
Instead of an actual attribute value of the tuple, logical locking can also be based
on a logical surrogate key , such as a number n that says that this was the nth tuple
that ever was inserted into the relation. However, when using surrogates, the lock
can be acquired only after the tuple and the surrogate attribute contained in it has
been found.
Still, some existing database management systems use physical locking instead
of logical locking. For instance, data pages or individual record positions in them
are locked. In page locking , the lock names are page identifiers or hash values
calculated from them. A lock on data page p locks all those data items of the logical
database that are currently present in p or that logically belong to p.In record
locking or record-identifier locking , the lock names are record identifiers, that is,
pairs .p; i / of page-ids and record positions (or hash values calculated from them).
Alockonrecord-id.p; i / locks the data item at position i in page p or a data item
that belongs there.
The granularity of record locking is close to that of locking unique keys. Page
locking is unnecessarily coarse, if the target of the operation is only a single data
item in the page. A page or record lock can be acquired only after the physical
location of the data item to be operated on is known. Page locks and record locks
held by a transaction T also have to be changed if the data items are moved to
another place while T is active. For instance, when T inserts a set of tuples into
a relation structured as a sparse B-tree and a leaf has to be split because of this
insertion, part of the tuples in the page is moved to another page. The page or record
locks have to be changed so as to reflect the new locations of the tuples.
Fine-granular physical locking (record locking) is feasible when the tuples of a
relation are stored in a data structure such as an unordered sequential file (heap)
where their locations do not change in normal update actions. A dense index is
then created on the base structure, for example, a B-tree whose leaf pages contain
records that point to the actual tuples. If the base structure needs to be reorganized,
a coarse-grained lock that is independent of the locations of the tuples (a relation
lock) is acquired.
9.4
Update-Mode Locks
Deadlocks caused by lock upgrades can be prevented by using update-mode locks
or Ulocks , for short. A transaction will acquire a U lock on data item x instead
of an S lock when it is possible that the lock needs to be upgraded to an X lock
later. In this protocol, an S lock cannot be upgraded to an X lock nor to a
U lock.
AUlockondataitemx can be acquired when no other transaction holds an
X lock or a U lock on x (i.e., the same as for an S lock). When a transaction has a
Search WWH ::




Custom Search