db2top Locks Screen

Locks

Today’s db2top screen is a very useful one for tracking down locking problems. You can use it to find lock waiters, lock holders and follow the chain from waiter to holder to diagnose the source of your long lock wait times.

You launch the Lock screen by holding the shift key and pressing the ‘U’ key. First, I’ll create a lock holder and a waiter. I will open two terminals, start the DB2 Command Line Processor (CLP) in each, connect to a database named ‘dpf’ and turn off auto-commit:

/home/kmcdonal> db2

(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.1

...

db2 => connect to dpf

Database Connection Information

Database server = DB2/LINUXX8664 9.7.1
SQL authorization ID = KMCDONAL
Local database alias = DPF

db2 => update command options using c off
DB20000I The UPDATE COMMAND OPTIONS command completed successfully.

From terminal 1, I will create a lock holder by creating a table and not committing it:

db2 => create table t1 (i1 integer)
DB20000I  The SQL command completed successfully.

From terminal 2, I will create a lock waiter by selecting from the uncommitted table:

db2 => select * from t1

Returning to the Locks screen, we see several entries for an application in “Lock Waiting” state and several more for an application in “UOW Waiting in the application” state, as shown below:

db2top Locks screen with 80 column width

Looking at the Locks screen, we see that it is made up of a column of three aggregates at the top and a table below. The aggregates are:

Name Definition
Locks held The number of locks currently held (locks_held) and, in brackets, the percentage of lock list storage consumed by held locks (locks_held / (locklist × 4096)).
Agents waiting The number of agents waiting on a lock (locks_waiting).
Appls Connected The number of applications that are currently connected to the database (appls_cur_cons).

The table is made up of the following columns, shown one screen at a time:

db2top Locks screen columns 1 to 3

Column Name Definition
Agent Id(State) A system-wide unique ID for the application (agent_id), together with a short code for the current status of the application (appl_status) in parentheses. Possible values for the status are:

c
Database Connect Completed (SQLM_CONNECTED) or
Database Connect Pending (SQLM_CONNECTPEND)
*
Unit of Work Executing (SQLM_UOWEXEC),
Pending remote request (SQLM_WAITFOR_REMOTE), or
Federated request pending (SQLM_REMOTE_RQST)
i
Unit of Work waiting (SQLM_UOWWAIT)
l
Lock Wait (SQLM_LOCKWAIT)
L
Data Fast Load (SQLM_LOAD)
?
All other states
Application Name The name of the application running at the client, as known to the database or DB2® Connect™ server (appl_name), truncated to 20 characters.
Application Status The current status of the application (appl_status). Shown in yellow if the application is active. Shown in red if the application is waiting on a lock. Possible values are:

  • Initializing (SQLM_INIT)
  • Connect Pending (SQLM_CONNECTPEND)
  • Connected (SQLM_CONNECTED)
  • UOW Executing (SQLM_UOWEXEC)
  • UOW Waiting in the application (SQLM_UOWWAIT)
  • Lock Waiting (SQLM_LOCKWAIT)
  • Commit Active (SQLM_COMMIT_ACT)
  • Rollback Active (SQLM_ROLLBACK_ACT)
  • Recompiling Plan (SQLM_RECOMP)
  • Compiling SQL Stmt (SQLM_COMP)
  • Request Interupted (SQLM_INTR)
  • Disconnect Pending (SQLM_DISCONNECTPEND)
  • Prepared Transaction (SQLM_TPREP)
  • Trans. heuristically committed (SQLM_THCOMT)
  • Trans. heuristically aborted (SQLM_THABRT)
  • Transaction ended (SQLM_TEND)
  • Creating Database (SQLM_CREATE_DB)
  • Restarting Database (SQLM_RESTART)
  • Restoring Database (SQLM_RESTORE)
  • Backing Up Database (SQLM_BACKUP)
  • Loading Database (SQLM_LOAD)
  • Unloading Database (SQLM_UNLOAD)
  • I/O Error Waiting (SQLM_IOERROR_WAIT)
  • Quiescing a Tablespace (SQLM_QUIESCE_TABLESPACE)
  • Waiting for remote node (SQLM_WAITFOR_REMOTE)
  • Pending results from remote request (SQLM_REMOTE_RQST)
  • Decoupled from coordinator (SQLM_DECOUPLED)
  • Rollback to savepoint (SQLM_ROLLBACK_TO_SAVEPOINT)
  • Unknown[x] where x is the value of an SQLM constant

db2top Locks screen columns 4 to 6

Column Name Definition
Object Name The type of object against which the application holds a lock (lock_object_type). If the lock is on a table, it reports table_schema . table_name for non-DPF systems and table_schema . table_name [data_partition_id] for DPF systems, both of which are truncated to 40 characters if necessary. Otherwise, it can have one of the following possible values:

  • Table (SQLM_TABLE_LOCK)
  • Table row (SQLM_ROW_LOCK)
  • Internal (SQLM_INTERNAL_LOCK)
  • Tablespace (SQLM_TABLESPACE_LOCK)
  • End of table (SQLM_EOT_LOCK)
  • Key Value (SQLM_KEY_VALUE_LOCK)
  • Internal Lock on Sysboot Table (SQLM_SYSBOOT_LOCK)
  • Internal Plan (SQLM_INTERALP_LOCK)
  • Internal Variation (SQLM_INTERNALV_LOCK)
  • Internal Sequence (SQLM_INTERNALS_LOCK)
  • Bufferpool (SQLM_INTERNALJ_LOCK)
  • Internal Long/Lob (SQLM_INTERNALL_LOCK)
  • Internal Catalog Cache (SQLM_INTERNALC_LOCK)
  • Internal Online Backup (SQLM_INTERNALB_LOCK)
  • Internal Object Table (SQLM_INTERNALO_LOCK)
  • Internal Table Alter (SQLM_INTERNALT_LOCK)
  • Internal DMS Sequence (SQLM_INTERNALQ_LOCK)
  • Inplace reorg (SQLM_INPLACE_REORGE_LOCK)
  • Block lock type (SQLM_BLOCK_LOCK)
  • Table partition (SQLM_TABLE_PART_LOCK)
  • Autoresize (SQLM_AUTORESIZE_LOCK)
  • Automatic storage (SQLM_AUTOSTORAGE_LOCK)
  • XML Path (SQLM_XML_PATH_LOCK)
  • Internal Extent Movement (SQLM_INTERNALM_LOCK)
  • Unknown[x] where x is a constant from sqlmon.h
Lock Mode

If requesting a lock, the lock requested and the lock held are both shown (lock_mode_requested[lock_mode]). Otherwise, just the lock held is shown (lock_mode). The lock requested and the lock held can each take on one of the following values:

  • N (SQLM_LNON)
  • IS (SQLM_LOIS)
  • IX (SQLM_LOIX)
  • S (SQLM_LOOS)
  • ISX (SQLM_LSIX)
  • X (SQLM_LOOX)
  • IN (SQLM_LOIN)
  • Z (SQLM_LOOZ)
  • U (SQLM_LOOU)
  • NS (SQLM_LONS)
  • NX (SQLM_LONX)
  • W (SQLM_LOOW)
  • NW (SQLM_LONW)
  • x [y] where x is the decimal representation of the SQLM constant from sqlmon.h and y is the hexdecimal representation of the same constant.
Object Type The type of object against which the application holds a lock (lock_object_type), expressed in short form with the following possible values:

  • Table (SQLM_TABLE_LOCK)
  • Row (SQLM_ROW_LOCK)
  • Int (SQLM_INTERNAL_LOCK)
  • Tbsp (SQLM_TABLESPACE_LOCK)
  • Eot (SQLM_EOT_LOCK)
  • Key (SQLM_KEY_VALUE_LOCK)
  • Sys (SQLM_SYSBOOT_LOCK)
  • Plan (SQLM_INTERALP_LOCK)
  • Variation (SQLM_INTERNALV_LOCK)
  • Sequence (SQLM_INTERNALS_LOCK)
  • Bps (SQLM_INTERNALJ_LOCK)
  • Long/Lob (SQLM_INTERNALL_LOCK)
  • Catlg (SQLM_INTERNALC_LOCK)
  • Backup (SQLM_INTERNALB_LOCK)
  • IntTbl (SQLM_INTERNALO_LOCK)
  • Alter (SQLM_INTERNALT_LOCK)
  • DMS (SQLM_INTERNALQ_LOCK)
  • Reorg (SQLM_INPLACE_REORGE_LOCK)
  • Block (SQLM_BLOCK_LOCK)
  • Table part (SQLM_TABLE_PART_LOCK)
  • Auto rsz (SQLM_AUTORESIZE_LOCK)
  • Auto stor (SQLM_AUTOSTORAGE_LOCK)
  • XML Path (SQLM_XML_PATH_LOCK)
  • Ext Mvnt (SQLM_INTERNALM_LOCK)
  • Unknown[x] where x is a constant from sqlmon.h

db2top Locks screen columns 7 to 11

Column Name Definition
Lock Status

The internal status of the lock (lock_status). It is shown as one of the following values:

  • Granted (SQLM_LRBGRNT)
  • Converting (SQLM_LRBCONV)
  • – (otherwise)
Lock Count The number of locks on the lock being held (lock_count). When a value of 255 is reported, this indicates that a transaction duration lock is being held. If no locks are being held, a “-” is reported.
Is Blocker It shows “Yes” in cyan if this application is holding a lock upon which another application is waiting. Otherwise, it shows “No”.
Locked By If locked by another application, this reports the application handle of the agent holding a lock for which this application is waiting (agent_id_holding_lock). Otherwise, “-” is shown.
Tablespace Name The name of the table space against which the application currently holds a lock (tablespace_name).

The footer at the bottom of the screen shows additional aggregate information:

Aggregate Name Definition
Lock= The number of lock holders measured across all locks on the database (sum(lock_count), where sum() is the sum across all applications and locks).
Entries= The number of locks held across all applications on the database (sum(locks_held), where sum() is the sum across all applications).

The footer also indicates how to invoke the Lock Chain screen.

As indicated in the footer, you can launch the Lock Chain screen by holding down the shift key and pressing the ‘L’ key. The Lock Chain screen looks like the following:

db2top Lock Chain screen

Here we see that application 65724 is waiting on a lock held by application 65725.