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.
This commit is contained in:
Abhijit Menon-Sen
2015-11-28 21:28:50 +05:30
committed by Ian Barwick
parent c93f717305
commit 882bfd9d8e

View File

@@ -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"));