From c0eea90402d4951311ed418fd661bb4a4c89c6c5 Mon Sep 17 00:00:00 2001 From: Gianni Ciolli Date: Thu, 18 Aug 2016 13:29:20 +0200 Subject: [PATCH] Cascading replication support for Barman mode If upstream_node is specified, we point the standby to that node; otherwise we point it to the current primary node. --- repmgr.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/repmgr.c b/repmgr.c index 6a8bea8d..a77ad511 100644 --- a/repmgr.c +++ b/repmgr.c @@ -5172,16 +5172,27 @@ create_recovery_file(const char *data_dir, PGconn *primary_conn, const char *con if (primary_conn == NULL) { char buf[MAXLEN]; + char where_condition[MAXLEN]; PQExpBufferData command_output; + switch(options.upstream_node) + { + case NO_UPSTREAM_NODE: + maxlen_snprintf(where_condition, "type='master'"); + default: + maxlen_snprintf(where_condition, "id=%d", options.upstream_node); + } + initPQExpBuffer(&command_output); maxlen_snprintf(buf, "ssh %s \"psql -Aqt \\\"%s\\\" -c \\\"" " SELECT conninfo" " FROM repmgr_%s.repl_nodes" - " WHERE type='master'" + " WHERE %s" " AND active" - "\\\"\"", options.barman_server, conninfo_on_barman, options.cluster_name); + "\\\"\"", + options.barman_server, conninfo_on_barman, + options.cluster_name, where_condition); (void)local_command(buf, &command_output); maxlen_snprintf(buf, "%s", command_output.data); string_remove_trailing_newlines(buf);