Locks for LOB data
The purpose of LOB locks is different from the purpose of regular transaction locks. A lock that is taken on a LOB value in a LOB table space is called a LOB lock.
LOB
data values might be stored separately from table space that contains
the values in the base table. The separate table space that contains LOB
values is called a LOB table space.However,
if inline LOBs are used, LOB data might be stored partly or entirely
within the base table space.
An application that reads or updates a row in a table that contains LOB columns obtains its normal transaction locks on the base table. The locks on the base table also control concurrency for the LOB table space. When locks are not acquired on the base table, such as for ISO(UR), Db2 maintains data consistency by using LOB locks.
LOB locks and uncommitted read isolation
When an application uses uncommitted read isolation to read the rows, no page or row locks are taken on the base table. Therefore, these readers must take an S LOB lock to ensure that they are not reading a partial LOB or a LOB value that is inconsistent with the base row. This LOB lock is acquired and released immediately, which is sufficient for Db2 to ensure that a complete copy of the LOB data is ready for subsequent reference.
Hierarchy of LOB locks
If the LOB table space is locked with a gross lock, then LOB locks are not acquired. In a data sharing environment, the lock on the LOB table space is used to determine whether the lock on the LOB must be propagated beyond the local IRLM.
When LOB table space locks are not taken
A lock might not be acquired on a LOB table space at all. For example, if a row is deleted from a table and the value of the LOB column is null, the LOB table space that is associated with that LOB column is not locked. Db2 does not access the LOB table space when the application takes any of the following actions:
- Selects a LOB that is null or zero length
- Deletes a row where the LOB is null or zero length
- Inserts a null or zero length LOB
- Updates a null or zero-length LOB to null or zero-length