From: Kyotaro Horiguchi Date: Fri, 3 Feb 2017 10:31:01 +0900 Subject: [PATCH] Refactor the lock section for subscription worker termination --- src/backend/commands/subscriptioncmds.c | 3 --- src/backend/replication/logical/launcher.c | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 3b70807..67c587c 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -508,9 +508,6 @@ DropSubscription(DropSubscriptionStmt *stmt) /* Clean up dependencies */ deleteSharedDependencyRecordsFor(SubscriptionRelationId, subid, 0); - /* Protect against launcher restarting the worker. */ - LWLockAcquire(LogicalRepLauncherLock, LW_EXCLUSIVE); - /* Kill the apply worker so that the slot becomes accessible. */ logicalrep_worker_stop(subid); diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index d222cff..233be06 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -368,6 +368,9 @@ logicalrep_worker_stop(Oid subid) break; } + /* Block the lauchner not to restart this worker */ + LWLockAcquire(LogicalRepLauncherLock); + /* Now terminate the worker ... */ kill(worker->proc->pid, SIGTERM); LWLockRelease(LogicalRepWorkerLock); @@ -398,6 +401,8 @@ logicalrep_worker_stop(Oid subid) ResetLatch(&MyProc->procLatch); } + + LWLockRelease(LogicalRepLauncherLock); } /* -- 2.9.2 ----Next_Part(Fri_Feb_03_10_56_35_2017_914)-- Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers ----Next_Part(Fri_Feb_03_10_56_35_2017_914)----