From c4a47c467fdf96af90b4b999616242c1dff462fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Marqu=C3=A9s?= Date: Fri, 6 Mar 2015 10:37:43 -0300 Subject: [PATCH] Add check for wal_level = logical so we don't fail on 9.4 On 9.4 we have logical decoding, which introduced a new wal_level called logical. This level includes all the previous ones, so you can run a hot_standby if wal_level = logical, because the relevant information for hot_standby will be there, plus other information needed for logical decoding. We fix this be adding a second check when wal_level is not hot_standby. --- repmgr.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/repmgr.c b/repmgr.c index c3f0c59d..b85a0a58 100644 --- a/repmgr.c +++ b/repmgr.c @@ -812,7 +812,7 @@ do_standby_clone(void) int r = 0, retval = SUCCESS; - int i, + int i,j, is_standby_retval; bool flag_success = false; bool test_mode = false; @@ -890,11 +890,30 @@ do_standby_clone(void) i = guc_set(conn, "wal_level", "=", "hot_standby"); if (i == 0 || i == -1) { - PQfinish(conn); if (i == 0) - log_err(_("%s needs parameter 'wal_level' to be set to 'hot_standby'\n"), - progname); - exit(ERR_BAD_CONFIG); + { + /* We could be using PG 9.4 with log_level logical, which is good enough for + hot standby replication. + We should check if the wal_level is set to that value, in which case we are + good to proceed. + No need to check if we are in 9.4 first, as the query used in guc_set will just + return zero rows if on < 9.4, and so will work anyway. + */ + j = guc_set(conn, "wal_level", "=", "logical"); + if (j == 0 || j == -1) + { + PQfinish(conn); + if (j == 0) + log_err(_("%s needs parameter 'wal_level' to be set to at least 'hot_standby'\n"), + progname); + exit(ERR_BAD_CONFIG); + } + } + else if (i == -1) + { + PQfinish(conn); + exit(ERR_BAD_CONFIG); + } } i = guc_set_typed(conn, "wal_keep_segments", ">=",