From 861a3c8f22e1470db22b3b536e5ccceccb819107 Mon Sep 17 00:00:00 2001 From: Jaime Casanova Date: Sat, 16 Jun 2012 01:32:59 -0500 Subject: [PATCH] Fix CLUSTER CLEANUP, it needs to establish a local connection in order to look for the master --- repmgr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/repmgr.c b/repmgr.c index 8075a9c2..0b589141 100644 --- a/repmgr.c +++ b/repmgr.c @@ -423,19 +423,26 @@ do_cluster_show(void) do_cluster_cleanup(void) { int master_id; + PGconn *conn = NULL; PGconn *master_conn = NULL; PGresult *res; char sqlquery[QUERY_STR_LEN]; + /* We need to connect to check configuration */ + log_info(_("%s connecting to database\n"), progname); + conn = establishDBConnection(options.conninfo, true); + /* check if there is a master in this cluster */ log_info(_("%s connecting to master database\n"), progname); - master_conn = getMasterConnection(master_conn, repmgr_schema, options.cluster_name, + master_conn = getMasterConnection(conn, repmgr_schema, options.cluster_name, &master_id, NULL); if (!master_conn) { log_err(_("cluster cleanup: cannot connect to master\n")); + PQfinish(conn); exit(ERR_DB_CON); } + PQfinish(conn); if (runtime_options.keep_history > 0) {