Locks and blocking
pg_locksDiagnose hung PostgreSQL queries by showing lock waits as a blocking tree with waiting sessions, lock holders, and root blockers.
Instructions
Show lock waits as a blocking tree: which sessions wait, for how long and for which lock or table, who holds it (pid, state, query, how long its transaction has been open), the root blockers with how many sessions each one blocks, the strong (ACCESS EXCLUSIVE) locks currently granted on user tables, and a count of locks by mode.
Use it when queries hang or pg_activity shows blocked_by. The wait time is counted
from the start of the waiting statement, so it is an upper bound. With
only_blocked=false it also lists the table locks every session holds or wants.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "pg_locks"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| connection | No | ||
| only_blocked | No |