diff options
author | Amit Kapila <akapila@postgresql.org> | 2023-01-18 09:03:12 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2023-01-18 09:03:12 +0530 |
commit | d540a02a724b9643205abce8c5644a0f0908f6e3 (patch) | |
tree | bb5103b31bfcbfb162bb1544c3e4766d66d13780 /src/backend/replication/logical/applyparallelworker.c | |
parent | 14bdb3f13de16523609d838b725540af5e23ddd3 (diff) | |
download | postgresql-d540a02a724b9643205abce8c5644a0f0908f6e3.tar.gz postgresql-d540a02a724b9643205abce8c5644a0f0908f6e3.zip |
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/backend/replication/logical/applyparallelworker.c')
-rw-r--r-- | src/backend/replication/logical/applyparallelworker.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/replication/logical/applyparallelworker.c b/src/backend/replication/logical/applyparallelworker.c index 3dfcff2798f..3579e704fe5 100644 --- a/src/backend/replication/logical/applyparallelworker.c +++ b/src/backend/replication/logical/applyparallelworker.c @@ -849,7 +849,7 @@ LogicalParallelApplyLoop(shm_mq_handle *mqh) static void pa_shutdown(int code, Datum arg) { - SendProcSignal(MyLogicalRepWorker->apply_leader_pid, + SendProcSignal(MyLogicalRepWorker->leader_pid, PROCSIG_PARALLEL_APPLY_MESSAGE, InvalidBackendId); @@ -932,7 +932,7 @@ ParallelApplyWorkerMain(Datum main_arg) error_mqh = shm_mq_attach(mq, seg, NULL); pq_redirect_to_shm_mq(seg, error_mqh); - pq_set_parallel_leader(MyLogicalRepWorker->apply_leader_pid, + pq_set_parallel_leader(MyLogicalRepWorker->leader_pid, InvalidBackendId); MyLogicalRepWorker->last_send_time = MyLogicalRepWorker->last_recv_time = @@ -950,7 +950,7 @@ ParallelApplyWorkerMain(Datum main_arg) * The parallel apply worker doesn't need to monopolize this replication * origin which was already acquired by its leader process. */ - replorigin_session_setup(originid, MyLogicalRepWorker->apply_leader_pid); + replorigin_session_setup(originid, MyLogicalRepWorker->leader_pid); replorigin_session_origin = originid; CommitTransactionCommand(); |