From 20d66df0efd180baa7c640db64273d91631a6589 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 19 Oct 2016 20:26:55 +0900 Subject: [PATCH] repmgr: prevent involuntary cloning where no repmgr schema present on master --- repmgr.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/repmgr.c b/repmgr.c index 8a76a1e2..f3c2ab79 100644 --- a/repmgr.c +++ b/repmgr.c @@ -2730,6 +2730,27 @@ do_standby_clone(void) } + + /* + * Sanity-check that the master node has a repmgr schema - if not + * present, fail with an error (unless -F/--force is used) + */ + + if (check_cluster_schema(primary_conn) == false) + { + if (!runtime_options.force) + { + /* schema doesn't exist */ + log_err(_("expected repmgr schema '%s' not found on master server\n"), get_repmgr_schema()); + log_hint(_("check that the master server was correctly registered\n")); + PQfinish(source_conn); + exit(ERR_BAD_CONFIG); + } + + log_warning(_("expected repmgr schema '%s' not found on master server\n"), get_repmgr_schema()); + } + + /* Fetch the source's data directory */ if (get_pg_setting(source_conn, "data_directory", master_data_directory) == false) { @@ -2751,6 +2772,8 @@ do_standby_clone(void) log_hint(_("use -D/--data-dir to explicitly specify a data directory\n")); } + + /* * Copy the source connection so that we have some default values, * particularly stuff like passwords extracted from PGPASSFILE; @@ -6106,6 +6129,7 @@ do_witness_register(PGconn *masterconn) log_notice(_("configuration has been successfully copied to the witness\n")); } + static void do_witness_unregister(void) {