From 77d52adb531c6fdeae3e07340777e2499628ac76 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 26 Nov 2015 11:23:05 +0900 Subject: [PATCH] Use existing config file options when attempting to connect to server during switchover --- repmgr.c | 14 ++++---------- repmgr.conf.sample | 5 +++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/repmgr.c b/repmgr.c index 4411124a..f6212b8a 100644 --- a/repmgr.c +++ b/repmgr.c @@ -931,7 +931,6 @@ do_master_register(void) } } - /* Now register the master */ record_created = create_node_record(conn, "master register", @@ -1218,8 +1217,6 @@ do_standby_clone(void) keywords[1] = "port"; values[1] = runtime_options.masterport; - /* XXX provide user too? */ - /* Connect to check configuration */ log_info(_("connecting to upstream node\n")); upstream_conn = establish_db_connection_by_params(keywords, values, true); @@ -2264,8 +2261,6 @@ do_standby_switchover(void) char remote_host[MAXLEN]; char remote_data_directory[MAXLEN]; int remote_node_id; - // make configurable? - int remote_reconnection_max_attempts = 10; char remote_node_replication_state[MAXLEN] = ""; int i, r = 0; @@ -2504,7 +2499,7 @@ do_standby_switchover(void) /* loop for timeout waiting for current primary to stop */ - for(i = 0; i < remote_reconnection_max_attempts; i++) + for(i = 0; i < options.reconnect_attempts; i++) { /* Check whether primary is available */ @@ -2526,7 +2521,7 @@ do_standby_switchover(void) PQfinish(remote_conn); // configurable? - sleep(1); + sleep(options.reconnect_interval); i++; } @@ -2579,7 +2574,7 @@ do_standby_switchover(void) connection_success = false; - for(i = 0; i < remote_reconnection_max_attempts; i++) + for(i = 0; i < options.reconnect_attempts; i++) { /* Check whether primary is available */ @@ -2598,8 +2593,7 @@ do_standby_switchover(void) } PQfinish(remote_conn); - // configurable? - sleep(1); + sleep(options.reconnect_interval); i++; } diff --git a/repmgr.conf.sample b/repmgr.conf.sample index bd0e5e8e..e67a2e4d 100644 --- a/repmgr.conf.sample +++ b/repmgr.conf.sample @@ -121,8 +121,9 @@ logfacility=STDERR master_response_timeout=60 -# Number of times to try and reconnect to the primary before starting -# the failover procedure +# Number of attempts at what interval (in seconds) to try and +# connect to a server to establish its status (e.g. master +# during failover) reconnect_attempts=6 reconnect_interval=10