Topic: Code Place
Subtopic: DB2 for LUW
Diagnosing and correcting lock timeout situations in large DB2 environments can be a complex and time consuming task. The DB2 snapshot monitor is useful in capturing information about the active locks in a database, but it often does not provide enough information to diagnose lock timeout situations. It may also not be possible to recreate the conditions that cause the lock timeout in order to use the snapshot monitor. The db2pd tool can also be used to capture diagnostic information at the time of a lock timeout. However, the information returned by db2pd needs more analysis and interpretation to determine the details pertinent to lock timeout situations. Script WhoOwnsLocks.ksh is a simple script - written in Korn shell - to quickly determine application handle(s) of application(s) holding locks on DB2 objects and application(s) waiting for those locks. Script uses awk, db2pd and sprintf tools to process db2pd commands to determine application handle(s) of owner(s) and waiter(s) for lock. Script was tested with DB2 UDB V8 and V9 on both AIX and Linux. Please keep in mind that format of the output produced by db2pd command most likely will be changed in the future as more and more enhancements are added. Usage: WhoOwnsLocks.ksh database_alias Sample output: $ ./whoownslocks.ksh sample Gathering input data ... Sending -locks output to D:\Cygwin\home\db2admin\locks1048. Sending -tcbstats output to D:\Cygwin\home\db2admin\table1048. Sending -transactions output to D:\Cygwin\home\db2admin\trans1048. Sending -version output to D:\Cygwin\home\db2admin\version1048. Processing input data ... Application handle 458 is holding lock(s); object(s) locked are in: Table name: ORG Schema name: DB2ADMIN Appl. handle 463 is waiting for object(s) locked by this application. Removing temporary files.. Done.
Click Here to Download
NOTE: These are only open to members of IDUG. If you are not a member, please CLICK HERE for more information.