diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 8344e4509b..c154eed34c 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -664,15 +664,13 @@ logicalrep_worker_attach(int slot) } /* - * Detach the worker (cleans up the worker info). + * Stop the parallel apply workers if any, and detach the leader apply + * worker (cleans up the worker info). */ static void logicalrep_worker_detach(void) { - /* - * If this is the leader apply worker then stop all the parallel apply - * workers previously started from here. - */ + /* Stop the parallel apply workers. */ if (!am_parallel_apply_worker() && !am_tablesync_worker()) { List *workers; diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 2bff1dbc74..e8aa661971 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -58,20 +58,18 @@ * parallel apply workers (max_parallel_apply_workers_per_subscription), but this * may waste some memory if no process is actually started. * - * The dynamic shared memory segment will contain (1) a shm_mq that can be + * The dynamic shared memory segment will contain (a) a shm_mq that can be * used to send changes in the transaction from leader apply worker to parallel - * apply worker (2) another shm_mq that can be used to send errors (and other + * apply worker (b) another shm_mq that can be used to send errors (and other * messages reported via elog/ereport) from the parallel apply worker to leader - * apply worker (3) necessary information to be shared among parallel apply - * workers and leader apply worker(i.e. in_parallel_apply_xact flag and the + * apply worker (c) necessary information to be shared among parallel apply + * workers and leader apply worker (i.e. in_parallel_apply_xact flag and the * corresponding LogicalRepWorker slot information). * - * 2) Write to temporary files and apply when the final commit arrives + * In case, no worker is available to handle the streamed transaction, we + * follow approach 2. * - * If streaming = true, or if streaming = parallel but there are not parallel - * apply workers available to handle the streamed transaction, the data is - * written to temporary files and then applied at once when the final commit - * arrives. + * 2) Write to temporary files and apply when the final commit arrives * * Unlike the regular (non-streamed) case, handling streamed transactions has * to handle aborts of both the toplevel transaction and subtransactions. This