How to determine the owner of a lock
Determine which transaction is holding the lock. Display information about the current locks by running the db2pd command with the -locks attribute.
Look for the row that has a "W", meaning waiting, in the Sts (status) column. The Owner column indicates which transaction is holding the lock. In the following example TranHdl 3 is waiting on a lock held be TranHdl 2 (indicated by 1 below).
db2pd -d <database> -locks showlocks
db2pd -alldbs - locks showlocks
Database Partition 0 -- Database SAMPLE -- Active -- Up 00:00:40
Locks:
TranHdl ... Sts Owner ...
2 ... G 2 ...
3 ... G 3 ...
2 ... G 2 ...
3 ... W 2 1 ...
2 ... G 2 ...
2 ... G 2 ...
2 ... G 2 ...
2 ... G 2 ...
Identify the application that is running the transaction that is holding the lock by running db2pd -transactions. In the example below we see that TranHdl 2(indicated by 1 ) is being run by AppHandl 12(indicated by 2 ).
db2pd -d <database> -tansactions transaction= < TranHdl >
Database Partition 0 -- Database SAMPLE -- Active -- Up 00:05:06
Transactions:
... AppHandl ... TranHdl Locks ...
... 12 2 ... 2 1 38 ...
.... 13 ... 3 5 ...
Identify the Agent ID that is running the application by running db2pd -agents.
db2pd -agents application=< AppHandl>
Database Partition 0 -- Database SAMPLE -- Active -- Up 00:06:15
Agents:
Current agents: 2
Idle agents: 0
Active agents: 2
Coordinator agents: 2
...
AppHandl ... AgentPid ... ClientPid Userid ClientNm
...
...
13 ... 749570 ... 434354 jmcmahon db2bp ...
... 12 2 ... 811172 ... 917706 jmcmahon db2bp ...