From d9f83cf620fbea66697220cb3933ab3ec9170155 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 12 Jan 2015 14:09:44 +0900 Subject: [PATCH] Replace hard-coded value with local_options.reconnect_attempts; --- repmgr.conf.sample | 2 +- repmgrd.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/repmgr.conf.sample b/repmgr.conf.sample index 38733a85..56d362d3 100644 --- a/repmgr.conf.sample +++ b/repmgr.conf.sample @@ -55,7 +55,7 @@ pg_bindir=/usr/bin/ # # change wait time for master; before we bail out and exit when the -# master disappears, we wait 6 * retry_promote_interval_secs seconds; +# master disappears, we wait reconnect_attempts * retry_promote_interval_secs seconds; # by default this would be half an hour (since sleep_delay default # value is 300) # diff --git a/repmgrd.c b/repmgrd.c index 61bba47b..80ff5111 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -509,6 +509,7 @@ witness_monitor(void) sleep(local_options.master_response_timeout); + /* Attempt to find the new master */ for (connection_retries = 0; connection_retries < local_options.reconnect_attempts; connection_retries++) { log_info( @@ -645,8 +646,8 @@ standby_monitor(void) if (local_options.failover == MANUAL_FAILOVER) { log_err(_("We couldn't reconnect to master. Now checking if another node has been promoted.\n")); - // ZZZ why 6 here? make config option? - for (connection_retries = 0; connection_retries < 6; connection_retries++) + + for (connection_retries = 0; connection_retries < local_options.reconnect_attempts; connection_retries++) { primary_conn = get_master_connection(my_local_conn, local_options.cluster_name, &primary_options.node, NULL); @@ -667,12 +668,7 @@ standby_monitor(void) local_options.retry_promote_interval_secs ); - /* - * wait local_options.retry_promote_interval_secs minutes - * before retries, after 6 failures (6 * - * local_options.monitor_interval_secs seconds) we stop - * trying - */ + sleep(local_options.retry_promote_interval_secs); } }