The pg_stat_activity view shows information for aux processes, but the
pg_stat_get_backend_wait_event() and
pg_stat_get_backend_wait_event_type() functions did not. To fix, call
AuxiliaryPidGetProc(pid) if BackendPidGetProc(pid) returns NULL, like
we do in pg_stat_get_activity().
In version 17 and above, it's a little silly to use those functions
when we already have the ProcNumber at hand, but it was necessary
before v17 because the backend ID was different from ProcNumber. I
have other plans for wait_event_info on master, so it doesn't seem
worth applying a different fix on different versions now.
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://www.postgresql.org/message-id/
c0320e04-6e85-4c49-80c5-
27cfb3a58108@iki.fi
Backpatch-through: 14
wait_event_type = "<backend information not available>";
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
wait_event_type = "<insufficient privilege>";
- else if ((proc = BackendPidGetProc(beentry->st_procpid)) != NULL)
- wait_event_type = pgstat_get_wait_event_type(proc->wait_event_info);
+ else
+ {
+ proc = BackendPidGetProc(beentry->st_procpid);
+ if (!proc)
+ proc = AuxiliaryPidGetProc(beentry->st_procpid);
+ if (proc)
+ wait_event_type = pgstat_get_wait_event_type(proc->wait_event_info);
+ }
if (!wait_event_type)
PG_RETURN_NULL();
wait_event = "<backend information not available>";
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
wait_event = "<insufficient privilege>";
- else if ((proc = BackendPidGetProc(beentry->st_procpid)) != NULL)
- wait_event = pgstat_get_wait_event(proc->wait_event_info);
+ else
+ {
+ proc = BackendPidGetProc(beentry->st_procpid);
+ if (!proc)
+ proc = AuxiliaryPidGetProc(beentry->st_procpid);
+ if (proc)
+ wait_event = pgstat_get_wait_event(proc->wait_event_info);
+ }
if (!wait_event)
PG_RETURN_NULL();