Example Outputs of db2pd Command | Generated by AI

Home PDF

Here are some example outputs of the db2pd -locks command and explanations of what the key information means:

Example 1: Basic db2pd -locks Output

Database Partition 0 -- Database SAMPLE -- Active -- Up 2 days 05:50:35

Locks:
Address            TranHdl    Lockname                   Type           Mode Sts Owner      Dur HoldCount  Att    ReleaseObj
0x0000000228A62400 5          00020006000000000000000054 Table          X    G   1         1   1          0      0x0000000000000000
0x0000000228A62600 6          00020006000000000000000054 Table          S    G   2         1   1          0      0x0000000000000000
0x0000000228A62800 7          00020006000000000000000054 Table          S    W   3         1   0          0      0x0000000000000000

Explanation:

In this example, we see:

Example 2: Detailed db2pd -locks detailed Output

Database Partition 0 -- Database SAMPLE -- Active -- Up 2 days 07:30:22

Locks:
Address            TranHdl    Lockname                   Type           Mode Sts Owner      Dur HoldCount  Att    ReleaseObj
0x0000000228A62400 12         00030008000000000000000054 Table          X    G   1025      1   1          0      0x0000000000000000
  Application Handle: 52
  Application ID: *LOCAL.db2inst1.220316190145
  Application Name: db2bp
  Authorization ID: DB2INST1
  Correlation Token: db2inst1.db2bp.220316231245.12
  Lock Mode: X (Exclusive)
  Lock Status: Granted
  Lock Reference Count: 1
  Lock Handle Count: 1
0x0000000228A62800 14         00030008000000000000000054 Table          S    W   1026      1   0          0      0x0000000000000000
  Application Handle: 53
  Application ID: *LOCAL.db2inst1.220316190226
  Application Name: db2bp.exe
  Authorization ID: DB2INST1
  Correlation Token: db2inst1.db2bp.220316231325.14
  Lock Mode: S (Share)
  Lock Status: Waiting
  Lock Reference Count: 0
  Lock Handle Count: 1
  Wait Start Time: 2022-03-16-19.03.25.712635
  Waited: 32 seconds

Explanation:

The detailed output provides significant additional information:

In this example:

Example 3: Lock Waits with db2pd -locks show waiters

Database Partition 0 -- Database SAMPLE -- Active -- Up 3 days 02:15:44

Lock Waiters:
Address            TranHdl    Lockname                   Type           Mode Sts Owner      Dur HoldCount  Att    ReleaseObj
0x0000000228A62800 22         00030008000000000000000054 Table          S    W   2048      1   0          0      0x0000000000000000

Lock Holders:
Address            TranHdl    Lockname                   Type           Mode Sts Owner      Dur HoldCount  Att    ReleaseObj
0x0000000228A62400 18         00030008000000000000000054 Table          X    G   2045      1   1          0      0x0000000000000000

Waiter-Holder Relationship:
Waiter (TranHdl=22, AppHdl=65) is waiting on:
   Holder (TranHdl=18, AppHdl=63)

Explanation:

This output specifically shows the relationship between waiting transactions and the transactions holding the locks they need:

In this example:

This information is extremely valuable for troubleshooting deadlocks or lock contention, as it clearly shows which applications are blocking others. You can use the application handles to force applications if necessary.

Key Insights from db2pd Output:

  1. Identifying Bottlenecks: Find tables with many locks or waiters
  2. Deadlock Detection: Identify circular wait conditions
  3. Lock Escalation: See when row locks are being escalated to table locks
  4. Long-Running Transactions: Identify transactions holding locks for extended periods
  5. Application Design Issues: Patterns of lock contention may indicate application design problems

The db2pd command is particularly valuable because it doesn’t require database connections and doesn’t affect performance significantly, making it safe to use in production environments.


Back 2025.03.24 Donate