From e42351ae07c19bb4eaedbdce8ccd4dfb4e905069 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 15 Aug 2017 15:13:06 -0400 Subject: [PATCH] Simplify some code in logical replication launcher Avoid unnecessary locking calls when a subscription is disabled. Author: Yugo Nagata --- src/backend/replication/logical/launcher.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 4c6d4b2772..6c894421a3 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -929,11 +929,14 @@ ApplyLauncherMain(Datum main_arg) Subscription *sub = (Subscription *) lfirst(lc); LogicalRepWorker *w; + if (!sub->enabled) + continue; + LWLockAcquire(LogicalRepWorkerLock, LW_SHARED); w = logicalrep_worker_find(sub->oid, InvalidOid, false); LWLockRelease(LogicalRepWorkerLock); - if (sub->enabled && w == NULL) + if (w == NULL) { last_start_time = now; wait_time = wal_retrieve_retry_interval; -- 2.40.0