From 8ead0042adaf8717538b7a5a3d1d4dd90f1ca808 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 23 May 2019 09:31:46 +0900 Subject: [PATCH] Miscellaneous comment and logging cleanup1 --- repmgr.c | 9 +++++---- repmgrd.c | 15 ++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/repmgr.c b/repmgr.c index 39e3616c..b65cd356 100644 --- a/repmgr.c +++ b/repmgr.c @@ -766,9 +766,8 @@ repmgrd_pause(PG_FUNCTION_ARGS) if (file == NULL) { - elog(DEBUG1, "unable to allocate %s", REPMGRD_STATE_FILE); + elog(WARNING, "unable to allocate %s", REPMGRD_STATE_FILE); - // XXX anything else we can do? log? PG_RETURN_VOID(); } @@ -783,8 +782,10 @@ repmgrd_pause(PG_FUNCTION_ARGS) pause ? 1 : 0); LWLockRelease(shared_state->lock); - // XXX check success - fwrite(buf.data, strlen(buf.data) + 1, 1, file); + if (fwrite(buf.data, strlen(buf.data) + 1, 1, file) != strlen(buf.data) + 1) + { + elog(WARNING, _("unable to write to file %s"), REPMGRD_STATE_FILE); + } resetStringInfo(&buf); diff --git a/repmgrd.c b/repmgrd.c index d55b3ff5..a91a382f 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -933,11 +933,10 @@ try_reconnect(PGconn **conn, t_node_info *node_info) log_notice(_("node %i has recovered, reconnecting"), node_info->node_id); /* - * XXX we should also handle the case where node is pingable but - * connection denied due to connection exhaustion - fall back to - * degraded monitoring? - make that configurable + * Note: we could also handle the case where node is pingable but + * connection denied due to connection exhaustion, by falling back to + * degraded monitoring (make configurable) */ - our_conn = establish_db_connection_by_params(&conninfo_params, false); if (PQstatus(our_conn) == CONNECTION_OK) @@ -948,7 +947,7 @@ try_reconnect(PGconn **conn, t_node_info *node_info) if (PQstatus(*conn) == CONNECTION_BAD) { - log_verbose(LOG_INFO, "original connection handle returned CONNECTION_BAD, using new connection"); + log_verbose(LOG_INFO, _("original connection handle returned CONNECTION_BAD, using new connection")); close_connection(conn); *conn = our_conn; } @@ -960,7 +959,7 @@ try_reconnect(PGconn **conn, t_node_info *node_info) if (ping_result != PGRES_TUPLES_OK) { - log_info("original connection no longer available, using new connection"); + log_info(_("original connection no longer available, using new connection")); close_connection(conn); *conn = our_conn; } @@ -978,7 +977,9 @@ try_reconnect(PGconn **conn, t_node_info *node_info) } close_connection(&our_conn); - log_notice(_("unable to reconnect to node %i"), node_info->node_id); + log_notice(_("unable to reconnect to node \"%s\" (ID: %i)"), + node_info->node_name, + node_info->node_id); } if (i + 1 < max_attempts)