From 1c49c4159c2f352b18830abe60f041dfe947d2b0 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 13 May 2016 17:27:11 -0300 Subject: [PATCH] Add -X stream parameter to pg_basebackup to ensure that we get all the WALs needed without needing to set wal_keep_segments to a ridiculously high value. This is not necessary on 9.6 if we are using replication slots, as all WAL segments needed will be kept on the primary until they are consumed by the slot. --- repmgr.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/repmgr.c b/repmgr.c index aa340b62..2c315891 100644 --- a/repmgr.c +++ b/repmgr.c @@ -4414,6 +4414,18 @@ run_basebackup(const char *data_dir) } } + /* + * To ensure we have all the WALs needed during basebackup execution we stream + * 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 + * creation time) + */ + if (server_version_num < 90600 || !options.use_replication_slots) + { + appendPQExpBuffer(¶ms, " -X stream"); + } + maxlen_snprintf(script, "%s -l \"repmgr base backup\" %s %s", make_pg_path("pg_basebackup"), @@ -4426,7 +4438,7 @@ run_basebackup(const char *data_dir) /* * As of 9.4, pg_basebackup only ever returns 0 or 1 - */ + */ r = system(script);