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.

Begin program-specific programming interface information.
Start of changeLOB data values might be stored separately from table space that contains the values in the base table. End of change The separate table space that contains LOB values is called a LOB table space.Start of changeHowever, if inline LOBs are used, LOB data might be stored partly or entirely within the base table space.End of change

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
    End program-specific programming interface information.