From f3d0ab9ab947f8e0f05bf31828cc5e5f63344f16 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 14 Jan 2016 09:33:08 +0900 Subject: [PATCH] Improve "archive_mode" configuration check There's no compelling reason to require "archive_mode" to be enabled for streaming replication. It is of course a good idea to archive WAL using e.g. barman ( http://www.pgbarman.org/ ) as part of a comprehensive backup strategy, but repmgr and streaming replication work fine without it. Per GitHub #141. Also revise the configuration check for "archive_command" to be triggered only when "archive_mode" is not "off", as from PostgreSQL 9.5 onwards "archive_mode" can also be "on" or "always". --- repmgr.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/repmgr.c b/repmgr.c index a6504b0e..06c51e5f 100644 --- a/repmgr.c +++ b/repmgr.c @@ -4314,31 +4314,18 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error) } } - i = guc_set(conn, "archive_mode", "=", "on"); - if (i == 0 || i == -1) - { - if (i == 0) - log_err(_("parameter 'archive_mode' must be set to 'on'\n")); - - if (exit_on_error == true) - { - PQfinish(conn); - exit(ERR_BAD_CONFIG); - } - - 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 enabled, check that 'archive_command' is non empty + * (however it's not practical to check that it actually represents a valid + * command). * - * 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. + * From PostgreSQL 9.5, archive_mode can be one of 'off', 'on' or 'always' + * so for ease of backwards compatibility, rather than explicitly check for an + * enabled mode, check that it's not "off". */ - if (guc_set(conn, "archive_mode", "=", "on")) + + if (guc_set(conn, "archive_mode", "!=", "off")) { i = guc_set(conn, "archive_command", "!=", ""); @@ -4360,9 +4347,11 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error) /* * Check that 'hot_standby' is on. This isn't strictly necessary - * for the primary server, however the assumption is that configuration - * should be consistent for all servers in a cluster. + * for the primary server, however the assumption is that we'll be + * cloning standbys and thus copying the primary configuration; + * this way the standby will be correctly configured by default. */ + i = guc_set(conn, "hot_standby", "=", "on"); if (i == 0 || i == -1) {