From 86d24759a065a3269a68db0c415d51123e717c65 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 18 Mar 2015 16:07:34 +0900 Subject: [PATCH] In configuration check, check that 'archive_command' is not empty --- repmgr.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/repmgr.c b/repmgr.c index b40076e0..c341a2d5 100644 --- a/repmgr.c +++ b/repmgr.c @@ -3031,8 +3031,8 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error) int i; bool config_ok = true; char *wal_error_message = NULL; - /* Check that WAL level is set correctly */ + /* Check that WAL level is set correctly */ if(server_version_num < 90300) { i = guc_set(conn, "wal_level", "=", "hot_standby"); @@ -3159,6 +3159,36 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error) config_ok = false; } + + /* + * check that 'archive_command' is non empty (however it's not practical to + * check that it's actually valid) + * + * if 'archive_mode' is not on, pg_settings returns '(disabled)' regardless + * of what's in 'archive_command', so until 'archive_mode' is on we can't + * properly check it. + */ + + if(guc_set(conn, "archive_mode", "=", "on")) + { + i = guc_set(conn, "archive_command", "!=", ""); + + if (i == 0 || i == -1) + { + if (i == 0) + log_err(_("parameter 'archive_command' must be set to a valid command\n")); + + if(exit_on_error == true) + { + PQfinish(conn); + exit(ERR_BAD_CONFIG); + } + + config_ok = false; + } + } + + i = guc_set(conn, "hot_standby", "=", "on"); if (i == 0 || i == -1) {