From 1db61ce2771a1b4310e488b5c557e202819838a0 Mon Sep 17 00:00:00 2001 From: Christian Kruse Date: Tue, 21 Jan 2014 13:53:40 +0100 Subject: [PATCH] fix: fail when repmgr_funcs is not pre-loaded when repmgr_funcs is not pre-loaded `repmgr_update_standby_location()` will return false and `repmgr_get_last_standby_location()` will return an empty string. Thus we may end in an endless loop. To avoid that we fail. --- repmgrd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/repmgrd.c b/repmgrd.c index 09b0b763..2ab6c8c0 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -951,8 +951,18 @@ do_failover(void) } if (sscanf(PQgetvalue(res, 0, 0), "%X/%X", &uxlogid, &uxrecoff) != 2) + { log_info(_("could not parse transaction log location \"%s\"\n"), PQgetvalue(res, 0, 0)); + /* we can't do anything but fail at this point... */ + if (*PQgetvalue(res, 0, 0) == '\0') + { + log_crit("Whoops, seems as if shared_preload_libraries=repmgr_funcs is not set!\n"); + exit(ERR_BAD_CONFIG); + } + } + + PQclear(res); PQfinish(nodeConn); /* If position is 0/0, keep checking */ @@ -1314,6 +1324,13 @@ update_shared_memory(char *last_wal_standby_applied) log_warning(_("Cannot update this standby's shared memory: %s\n"), PQerrorMessage(myLocalConn)); /* XXX is this enough reason to terminate this repmgrd? */ } + else if (strcmp(PQgetvalue(res, 0, 0), "f") == 0) + { + /* this surely is more than enough reason to exit */ + log_warning(_("Cannot update this standby's shared memory, maybe shared_preload_libraries=repmgr_funcs is not set?\n")); + exit(ERR_BAD_CONFIG); + } + PQclear(res); }