From 76cc11b786811e9c612ef8ff7a0d38de8824e450 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 7 Feb 2018 16:34:01 +0900 Subject: [PATCH] Fix "standby clone" in Barman mode with --no-upstream-connection "--upstream-node-id", if provided, was not being passed through to the SQL query executed via the Barman server. Also modified the query to select the primary node if "--upstream-node-id" is not provided. Note: this is a very niche use case. --- repmgr-action-standby.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index e477ed46..7620b01a 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -237,6 +237,9 @@ do_standby_clone(void) */ check_source_server(); } + else { + upstream_node_id = runtime_options.upstream_node_id; + } /* * if --upstream-conninfo was supplied, use that (will overwrite value set @@ -3344,8 +3347,14 @@ check_source_server_via_barman() "repmgr database conninfo string on barman server: %s", repmgr_conninfo_buf.data); - /* XXX check this works in all cases */ - maxlen_snprintf(where_condition, "node_id=%i", upstream_node_id); + if (upstream_node_id == UNKNOWN_NODE_ID) + { + maxlen_snprintf(where_condition, "type='primary' AND active IS TRUE"); + } + else + { + maxlen_snprintf(where_condition, "node_id=%i", upstream_node_id); + } initPQExpBuffer(&command_output); maxlen_snprintf(buf,