waits: wait events
Captured on 2026-09-27 (UTC+08) on a local KingbaseES V008R006C009B0014 primary and standby, database test, using ~/kbdiag built from Go source commit 93bf65d (static linux/amd64 binary). This is lab evidence, not production validation. The sessions in the examples were created by fault-injection scripts: two sessions idle in transaction, two waiting for table locks, and a pg_sleep(3600). PIDs, counts and timings belong to this capture only.
Usage
No options of its own. Connection options are the same as for sessions.
Default output
not idlegroups the sessions that are doing something by wait event and state.sessionscounts them andpidslists them. The biggest group comes first, since a pile-up is what to look for; on a tieactivecomes first.Lock:relation: two sessions wait for table locks; who blocks them and for how long is inlocks.Client:ClientReadwithidle in transaction: the sessions wait for their client to send the next statement while holding a transaction open.Timeout:PgSleepis the injectedpg_sleep. An active session with no wait event shows(running): on CPU, or in code without a wait event.pidslists up to 10 PIDs, then... (+N).--jsonhas them all.not showncounts what is left out.idlesessions do not answer “where is it stuck”. Nor do background processes idling in their main loop (anyActivitywait, such as a walsender with nothing to send or the checkpointer between checkpoints). A background process stuck on a real wait, for example the checkpointer onIO:DataFileSync, is listed with the state(background).
There are no thresholds and no options. Ten sessions waiting on IO can be an incident on one database and routine on another, so waits only reports. A lock wait that is too long is judged by locks.
A quiet primary:
On a busy primary a walsender catching up may appear with a wait such as IO:WALRead; that is normal.
On a standby
Insufficient privilege
Connect as kbdiag_ro, which has no monitoring role:
- Other users’ sessions have no visible wait event or state. They may be idle or not, so they are counted as
hidden (state unknown), not as idle. Sessions that turned offtrack_activitiesare counted asuntracked (state unknown)for the same reason. - With hidden sessions kbdiag cannot claim nothing is waiting, so the verdict is UNKNOWN, exit code 3. Grant
sys_monitorto see everything.
JSON
--json has every group, idle and background ones included, with the full PID lists: wait_event_type, wait_event, state, sessions and pids.
Exit codes
| Code | Meaning |
|---|---|
| 0 | OK |
| 3 | UNKNOWN: data not collected or not visible |
| 64 | Usage error |
| 69 | Cannot connect |