diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index dc49177c78..7dcddf478a 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -687,12 +687,9 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser leader_pid integer - Process ID of the parallel group leader if this process is or - has been involved in parallel query, or null. This field is set - when a process wants to cooperate with parallel workers, and - remains set as long as the process exists. For a parallel group leader, - this field is set to its own process ID. For a parallel worker, - this field is set to the process ID of the parallel group leader. + Process ID of the parallel group leader, if this process is a + parallel query worker. NULL if this process is a + parallel group leader or does not participate in parallel query. diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 2aff739466..95738a4e34 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -735,7 +735,13 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) wait_event = pgstat_get_wait_event(raw_wait_event); leader = proc->lockGroupLeader; - if (leader) + + /* + * Show the leader only for active parallel workers. This + * leaves the field as NULL for the leader of a parallel + * group. + */ + if (leader && leader->pid != beentry->st_procpid) { values[29] = Int32GetDatum(leader->pid); nulls[29] = false;