diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2017-06-01 23:05:47 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2017-06-01 23:16:20 -0400 |
commit | 6812330f1cc95f258ffe4ce7d56bdd56efbd9fde (patch) | |
tree | 7f48cb78927ea2534827976231fc90fc8af02325 /src | |
parent | 2d460179baa8744e9e2a183a5121306596c53fba (diff) | |
download | postgresql-6812330f1cc95f258ffe4ce7d56bdd56efbd9fde.tar.gz postgresql-6812330f1cc95f258ffe4ce7d56bdd56efbd9fde.zip |
Reorganize logical replication worker disconnect code
Move the walrcv_disconnect() calls into the before_shmem_exit handler.
This makes sure the call is always made even during exit by signal, it
saves some duplicate code, and it makes the logic more similar to
walreceiver.c.
Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/replication/logical/launcher.c | 6 | ||||
-rw-r--r-- | src/backend/replication/logical/tablesync.c | 1 | ||||
-rw-r--r-- | src/backend/replication/logical/worker.c | 8 |
3 files changed, 6 insertions, 9 deletions
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index b956052014b..63d903ac021 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -614,7 +614,13 @@ logicalrep_launcher_onexit(int code, Datum arg) static void logicalrep_worker_onexit(int code, Datum arg) { + /* Disconnect gracefully from the remote side. */ + if (wrconn) + walrcv_disconnect(wrconn); + logicalrep_worker_detach(); + + ApplyLauncherWakeup(); } /* SIGTERM: set flag to exit at next convenient time */ diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index fe45fb88203..515724e1026 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -140,7 +140,6 @@ finish_sync_worker(void) CommitTransactionCommand(); /* Stop gracefully */ - walrcv_disconnect(wrconn); proc_exit(0); } diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index c67720bd2fd..ea3ba1d5b48 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -1329,7 +1329,6 @@ reread_subscription(void) "stop because the subscription was removed", MySubscription->name))); - walrcv_disconnect(wrconn); proc_exit(0); } @@ -1344,7 +1343,6 @@ reread_subscription(void) "stop because the subscription was disabled", MySubscription->name))); - walrcv_disconnect(wrconn); proc_exit(0); } @@ -1359,7 +1357,6 @@ reread_subscription(void) "restart because the connection information was changed", MySubscription->name))); - walrcv_disconnect(wrconn); proc_exit(0); } @@ -1374,7 +1371,6 @@ reread_subscription(void) "restart because subscription was renamed", MySubscription->name))); - walrcv_disconnect(wrconn); proc_exit(0); } @@ -1392,7 +1388,6 @@ reread_subscription(void) "restart because the replication slot name was changed", MySubscription->name))); - walrcv_disconnect(wrconn); proc_exit(0); } @@ -1407,7 +1402,6 @@ reread_subscription(void) "restart because subscription's publications were changed", MySubscription->name))); - walrcv_disconnect(wrconn); proc_exit(0); } @@ -1610,8 +1604,6 @@ ApplyWorkerMain(Datum main_arg) /* Run the main loop. */ LogicalRepApplyLoop(origin_startpos); - walrcv_disconnect(wrconn); - /* We should only get here if we received SIGTERM */ proc_exit(0); } |