From d540a02a724b9643205abce8c5644a0f0908f6e3 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Wed, 18 Jan 2023 09:03:12 +0530 Subject: Display the leader apply worker's PID for parallel apply workers. Add leader_pid to pg_stat_subscription. leader_pid is the process ID of the leader apply worker if this process is a parallel apply worker. If this field is NULL, it indicates that the process is a leader apply worker or a synchronization worker. The new column makes it easier to distinguish parallel apply workers from other kinds of workers and helps to identify the leader for the parallel workers corresponding to a particular subscription. Additionally, update the leader_pid column in pg_stat_activity as well to display the PID of the leader apply worker for parallel apply workers. Author: Hou Zhijie Reviewed-by: Peter Smith, Sawada Masahiko, Amit Kapila, Shveta Mallik Discussion: https://postgr.es/m/CAA4eK1+wyN6zpaHUkCLorEWNx75MG0xhMwcFhvjqm2KURZEAGw@mail.gmail.com --- doc/src/sgml/logical-replication.sgml | 3 ++- doc/src/sgml/monitoring.sgml | 36 +++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 11 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 54f48be87f3..f4b4e641beb 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -1692,7 +1692,8 @@ CONTEXT: processing remote data for replication origin "pg_16395" during "INSER subscription. A disabled subscription or a crashed subscription will have zero rows in this view. If the initial data synchronization of any table is in progress, there will be additional workers for the tables - being synchronized. + being synchronized. Moreover, if the streaming transaction is applied in + parallel, there may be additional parallel apply workers. diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 358d2ff90f8..e3a783abd0f 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -743,9 +743,11 @@ 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 a - parallel query worker. NULL if this process is a - parallel group leader or does not participate in parallel query. + Process ID of the parallel group leader if this process is a parallel + query worker, or process ID of the leader apply worker if this process + is a parallel apply worker. NULL indicates that this + process is a parallel group leader or leader apply worker, or does not + participate in any parallel operation. @@ -3206,13 +3208,24 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i + + + leader_pid integer + + + Process ID of the leader apply worker if this process is a parallel + apply worker; NULL if this process is a leader apply worker or a + synchronization worker + + + relid oid - OID of the relation that the worker is synchronizing; null for the - main apply worker + OID of the relation that the worker is synchronizing; NULL for the + leader apply worker and parallel apply workers @@ -3222,7 +3235,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i Last write-ahead log location received, the initial value of - this field being 0 + this field being 0; NULL for parallel apply workers @@ -3231,7 +3244,8 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i last_msg_send_time timestamp with time zone - Send time of last message received from origin WAL sender + Send time of last message received from origin WAL sender; NULL for + parallel apply workers @@ -3240,7 +3254,8 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i last_msg_receipt_time timestamp with time zone - Receipt time of last message received from origin WAL sender + Receipt time of last message received from origin WAL sender; NULL for + parallel apply workers @@ -3249,7 +3264,8 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i latest_end_lsn pg_lsn - Last write-ahead log location reported to origin WAL sender + Last write-ahead log location reported to origin WAL sender; NULL for + parallel apply workers @@ -3259,7 +3275,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i Time of last write-ahead log location reported to origin WAL - sender + sender; NULL for parallel apply workers -- cgit v1.2.3