diff options
| author | Amit Kapila | 2023-01-18 03:33:12 +0000 |
|---|---|---|
| committer | Amit Kapila | 2023-01-18 03:33:12 +0000 |
| commit | d540a02a724b9643205abce8c5644a0f0908f6e3 (patch) | |
| tree | bb5103b31bfcbfb162bb1544c3e4766d66d13780 /src/include | |
| parent | 14bdb3f13de16523609d838b725540af5e23ddd3 (diff) | |
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
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
| -rw-r--r-- | src/include/catalog/pg_proc.dat | 6 | ||||
| -rw-r--r-- | src/include/replication/logicallauncher.h | 2 | ||||
| -rw-r--r-- | src/include/replication/worker_internal.h | 4 |
4 files changed, 8 insertions, 6 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 2afed46b89..fe35d7c76a 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -57,6 +57,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 202301131 +#define CATALOG_VERSION_NO 202301181 #endif diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 3810de7b22..86eb8e8c58 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -5430,9 +5430,9 @@ proname => 'pg_stat_get_subscription', prorows => '10', proisstrict => 'f', proretset => 't', provolatile => 's', proparallel => 'r', prorettype => 'record', proargtypes => 'oid', - proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}', - proargmodes => '{i,o,o,o,o,o,o,o,o}', - proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}', + proallargtypes => '{oid,oid,oid,int4,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}', + proargmodes => '{i,o,o,o,o,o,o,o,o,o}', + proargnames => '{subid,subid,relid,pid,leader_pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}', prosrc => 'pg_stat_get_subscription' }, { oid => '2026', descr => 'statistics: current backend PID', proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r', diff --git a/src/include/replication/logicallauncher.h b/src/include/replication/logicallauncher.h index c85593ad11..360e98702a 100644 --- a/src/include/replication/logicallauncher.h +++ b/src/include/replication/logicallauncher.h @@ -27,4 +27,6 @@ extern void AtEOXact_ApplyLauncher(bool isCommit); extern bool IsLogicalLauncher(void); +extern pid_t GetLeaderApplyWorkerPid(pid_t pid); + #endif /* LOGICALLAUNCHER_H */ diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h index db891eea8a..dc87a4edd1 100644 --- a/src/include/replication/worker_internal.h +++ b/src/include/replication/worker_internal.h @@ -71,7 +71,7 @@ typedef struct LogicalRepWorker * PID of leader apply worker if this slot is used for a parallel apply * worker, InvalidPid otherwise. */ - pid_t apply_leader_pid; + pid_t leader_pid; /* Indicates whether apply can be performed in parallel. */ bool parallel_apply; @@ -303,7 +303,7 @@ extern void pa_decr_and_wait_stream_block(void); extern void pa_xact_finish(ParallelApplyWorkerInfo *winfo, XLogRecPtr remote_lsn); -#define isParallelApplyWorker(worker) ((worker)->apply_leader_pid != InvalidPid) +#define isParallelApplyWorker(worker) ((worker)->leader_pid != InvalidPid) static inline bool am_tablesync_worker(void) |
