From a336d22bd966e5de29162a42a11f62e68ca2b24f Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 26 Dec 2016 09:57:58 +0900 Subject: [PATCH] repmgr: miscelleanous code cleanup --- dbutils.c | 9 +++++---- repmgr.c | 26 ++++++++++++++++++-------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/dbutils.c b/dbutils.c index b93ae267..76925025 100644 --- a/dbutils.c +++ b/dbutils.c @@ -1436,10 +1436,11 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id, bool success = true; struct tm ts; - /* Only attempt to write a record if a connection handle was provided. - Also check that the repmgr schema has been properly intialised - if - not it means no configuration file was provided, which can happen with - e.g. `repmgr standby clone`, and we won't know which schema to write to. + /* + * Only attempt to write a record if a connection handle was provided. + * Also check that the repmgr schema has been properly initialised - if + * not it means no configuration file was provided, which can happen with + * e.g. `repmgr standby clone`, and we won't know which schema to write to. */ if (conn != NULL && strcmp(repmgr_schema, DEFAULT_REPMGR_SCHEMA_PREFIX) != 0) { diff --git a/repmgr.c b/repmgr.c index 7e04ae6f..cb2dd2e3 100644 --- a/repmgr.c +++ b/repmgr.c @@ -1841,7 +1841,15 @@ do_cluster_cleanup(void) sqlquery_snprintf(sqlquery, "VACUUM %s.repl_monitor", get_repmgr_schema_quoted(master_conn)); res = PQexec(master_conn, sqlquery); - /* XXX There is any need to check this VACUUM happens without problems? */ + if (PQresultStatus(res) != PGRES_COMMAND_OK) + { + /* + * Unlikely to happen and not a problem per-se, but we'll issue a warning + * just in case + */ + log_warning(_("Unable to vacuum table %s.repl_monitor"), get_repmgr_schema_quoted(master_conn)); + } + PQclear(res); PQfinish(master_conn); @@ -2521,17 +2529,19 @@ get_tablespace_data(PGconn *upstream_conn, TablespaceDataList *list) res = PQexec(upstream_conn, sqlquery); if (PQresultStatus(res) != PGRES_TUPLES_OK) - { - log_err(_("unable to execute tablespace query: %s\n"), - PQerrorMessage(upstream_conn)); + { + log_err(_("unable to execute tablespace query: %s\n"), + PQerrorMessage(upstream_conn)); - PQclear(res); + PQclear(res); - return ERR_DB_QUERY; - } + return ERR_DB_QUERY; + } for (i = 0; i < PQntuples(res); i++) - tablespace_data_append(list, PQgetvalue(res, i, 0), PQgetvalue(res, i, 1), + tablespace_data_append(list, + PQgetvalue(res, i, 0), + PQgetvalue(res, i, 1), PQgetvalue(res, i, 2)); PQclear(res);