mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
From PostgreSQL 9.6, use pg_basebackup's -S/--slot option if appropriate
GitHub #206
This commit is contained in:
28
repmgr.c
28
repmgr.c
@@ -4640,7 +4640,7 @@ run_basebackup(const char *data_dir, int server_version)
|
|||||||
* Connection parameters not passed to repmgr as conninfo string - provide
|
* Connection parameters not passed to repmgr as conninfo string - provide
|
||||||
* them individually to pg_basebackup (-d/--dbname not required)
|
* them individually to pg_basebackup (-d/--dbname not required)
|
||||||
*/
|
*/
|
||||||
if (conninfo_provided == false)
|
else
|
||||||
{
|
{
|
||||||
if (strlen(runtime_options.host))
|
if (strlen(runtime_options.host))
|
||||||
{
|
{
|
||||||
@@ -4673,11 +4673,11 @@ run_basebackup(const char *data_dir, int server_version)
|
|||||||
/*
|
/*
|
||||||
* To ensure we have all the WALs needed during basebackup execution we stream
|
* To ensure we have all the WALs needed during basebackup execution we stream
|
||||||
* them as the backup is taking place.
|
* them as the backup is taking place.
|
||||||
* Not necessary if on 9.6 if we have replication slots set in repmgr.conf
|
*
|
||||||
* (starting at 9.6 there is an option, which we use, to reserve the LSN at
|
* From 9.6, if replication slots are in use, we'll have previously
|
||||||
* creation time)
|
* created a slot with reserved LSN, and will stream from that slot to avoid
|
||||||
|
* WAL buildup on the master using the -S/--slot, which requires -X/--xlog-method=stream
|
||||||
*/
|
*/
|
||||||
if (server_version < 90600 || !options.use_replication_slots)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We're going to check first if the user set the xlog method in the repmgr.conf
|
* We're going to check first if the user set the xlog method in the repmgr.conf
|
||||||
@@ -4692,6 +4692,24 @@ run_basebackup(const char *data_dir, int server_version)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From 9.6, pg_basebackup accepts -S/--slot, which forces WAL streaming to use
|
||||||
|
* the specified replication slot. If replication slot usage is specified, the
|
||||||
|
* slot will already have been created
|
||||||
|
*
|
||||||
|
* XXX verify that -X/--xlog-method is set to "stream"
|
||||||
|
*/
|
||||||
|
if (server_version >= 90600 && options.use_replication_slots)
|
||||||
|
{
|
||||||
|
const char slot_short[4] = "-S ";
|
||||||
|
const char slot_long[7] = "--slot";
|
||||||
|
|
||||||
|
if (strstr(options.pg_basebackup_options, slot_short) == NULL && strstr(options.pg_basebackup_options, slot_long) == NULL )
|
||||||
|
{
|
||||||
|
appendPQExpBuffer(¶ms, " -S %s", repmgr_slot_name_ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
maxlen_snprintf(script,
|
maxlen_snprintf(script,
|
||||||
"%s -l \"repmgr base backup\" %s %s",
|
"%s -l \"repmgr base backup\" %s %s",
|
||||||
make_pg_path("pg_basebackup"),
|
make_pg_path("pg_basebackup"),
|
||||||
|
|||||||
Reference in New Issue
Block a user