Simplify some of the logical replication worker-type checks.
authorAmit Kapila <akapila@postgresql.org>
Fri, 4 Aug 2023 02:45:07 +0000 (08:15 +0530)
committerAmit Kapila <akapila@postgresql.org>
Fri, 4 Aug 2023 02:45:07 +0000 (08:15 +0530)
Author: Peter Smith
Reviewed-by: Hou Zhijie
Discussion: http://postgr.es/m/CAHut+Pv-xkEpuPzbEJ=ZSi7Hp2RoGJf=VA-uDRxLi1KHSneFjg@mail.gmail.com

src/backend/replication/logical/worker.c

index a9f5fa7dfc0f83c83afe39a55e2958f9934aaf90..a20d4c11716b6855ff980051df951dd86cbf7c1b 100644 (file)
@@ -3863,7 +3863,7 @@ apply_worker_exit(void)
     * subscription is still active, and so that we won't leak that hash table
     * entry if it isn't.
     */
-   if (!am_tablesync_worker())
+   if (am_leader_apply_worker())
        ApplyLauncherForgetWorkerStartTime(MyLogicalRepWorker->subid);
 
    proc_exit(0);
@@ -3906,8 +3906,9 @@ maybe_reread_subscription(void)
                        MySubscription->name)));
 
        /* Ensure we remove no-longer-useful entry for worker's start time */
-       if (!am_tablesync_worker() && !am_parallel_apply_worker())
+       if (am_leader_apply_worker())
            ApplyLauncherForgetWorkerStartTime(MyLogicalRepWorker->subid);
+
        proc_exit(0);
    }
 
@@ -4589,8 +4590,9 @@ InitializeLogRepWorker(void)
                        MyLogicalRepWorker->subid)));
 
        /* Ensure we remove no-longer-useful entry for worker's start time */
-       if (!am_tablesync_worker() && !am_parallel_apply_worker())
+       if (am_leader_apply_worker())
            ApplyLauncherForgetWorkerStartTime(MyLogicalRepWorker->subid);
+
        proc_exit(0);
    }
 
@@ -4715,7 +4717,7 @@ DisableSubscriptionAndExit(void)
    CommitTransactionCommand();
 
    /* Ensure we remove no-longer-useful entry for worker's start time */
-   if (!am_tablesync_worker() && !am_parallel_apply_worker())
+   if (am_leader_apply_worker())
        ApplyLauncherForgetWorkerStartTime(MyLogicalRepWorker->subid);
 
    /* Notify the subscription has been disabled and exit */