aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2017-04-28 06:35:00 +0900
committerFujii Masao <fujii@postgresql.org>2017-04-28 06:35:00 +0900
commit9f11fcec6624511ca85c1a6b049201be1fed6ef4 (patch)
tree92cc2f7eb20ea59a43d797e0f9c0284071e191ca
parent82ebbeb0abfe40fe5f19a6fcdffc7484fd3a35b0 (diff)
downloadpostgresql-9f11fcec6624511ca85c1a6b049201be1fed6ef4.tar.gz
postgresql-9f11fcec6624511ca85c1a6b049201be1fed6ef4.zip
Fix bug so logical rep launcher saves correctly time of last startup of worker.
Previously the logical replication launcher stored the last timestamp when it started the worker, in the local variable "last_start_time", in order to check whether wal_retrive_retry_interval elapsed since the last startup of worker. If it has elapsed, the launcher sees pg_subscription and starts new worker if necessary. This is for limitting the startup of worker to once a wal_retrieve_retry_interval. The bug was that the variable "last_start_time" was defined and always initialized with 0 at the beginning of the launcher's main loop. So even if it's set to the last timestamp in later phase of the loop, it's always reset to 0. Therefore the launcher could not check correctly whether wal_retrieve_retry_interval elapsed since the last startup. This patch moves the variable "last_start_time" outside the main loop so that it will not be reset. Reviewed-by: Petr Jelinek Discussion: http://postgr.es/m/CAHGQGwGJrPO++XM4mFENAwpy1eGXKsGdguYv43GUgLgU-x8nTQ@mail.gmail.com
-rw-r--r--src/backend/replication/logical/launcher.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 549b612e9ae..cf0cb37acc6 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -781,6 +781,8 @@ ApplyLauncherWakeup(void)
void
ApplyLauncherMain(Datum main_arg)
{
+ TimestampTz last_start_time = 0;
+
ereport(DEBUG1,
(errmsg("logical replication launcher started")));
@@ -812,7 +814,6 @@ ApplyLauncherMain(Datum main_arg)
MemoryContext subctx;
MemoryContext oldctx;
TimestampTz now;
- TimestampTz last_start_time = 0;
long wait_time = DEFAULT_NAPTIME_PER_CYCLE;
now = GetCurrentTimestamp();