From 88a6a1376ef44bb3bd41e84c17f4b9ffbcc0c82b Mon Sep 17 00:00:00 2001 From: Abhijit Menon-Sen Date: Sat, 28 Nov 2015 21:28:50 +0530 Subject: [PATCH] If we're using replication slots, we need to create them earlier Otherwise, if the backup takes a long time, we might lose WAL we need long before we create the slot. --- repmgr.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/repmgr.c b/repmgr.c index 6553b122..437646b6 100644 --- a/repmgr.c +++ b/repmgr.c @@ -1399,6 +1399,20 @@ do_standby_clone(void) log_hint(_("this may take some time; consider using the -c/--fast-checkpoint option\n")); } + /* + * If replication slots requested, create appropriate slot on + * the primary; this must be done before pg_start_backup() is + * issued, either by us or by pg_basebackup. + */ + if (options.use_replication_slots) + { + if (create_replication_slot(upstream_conn, repmgr_slot_name) == false) + { + PQfinish(upstream_conn); + exit(ERR_DB_QUERY); + } + } + if (runtime_options.rsync_only) { PQExpBufferData tablespace_map; @@ -1746,20 +1760,6 @@ stop_backup: /* Finally, write the recovery.conf file */ create_recovery_file(local_data_directory); - /* - * If replication slots requested, create appropriate slot on the primary; - * create_recovery_file() will already have written `primary_slot_name` into - * `recovery.conf` - */ - if (options.use_replication_slots) - { - if (create_replication_slot(upstream_conn, repmgr_slot_name) == false) - { - PQfinish(upstream_conn); - exit(ERR_DB_QUERY); - } - } - if (runtime_options.rsync_only) { log_notice(_("standby clone (using rsync) complete\n"));