From 62d53b762291cb2085b00d596dff19d9abe3c6e6 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 30 Nov 2015 12:38:51 +0900 Subject: [PATCH] Drop a previously created replication slot if base backup fails for any reason Per Github #129 --- repmgr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/repmgr.c b/repmgr.c index f6212b8a..5870011a 100644 --- a/repmgr.c +++ b/repmgr.c @@ -1785,9 +1785,16 @@ stop_backup: /* If the backup failed then exit */ if (r != 0) { + /* If a replication slot was previously created, drop it */ + if (options.use_replication_slots) + { + drop_replication_slot(upstream_conn, repmgr_slot_name); + } + log_err(_("unable to take a base backup of the master server\n")); log_warning(_("destination directory (%s) may need to be cleaned up manually\n"), local_data_directory); + PQfinish(upstream_conn); exit(retval); }