aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/pg_recvlogical.c
diff options
context:
space:
mode:
authorMasahiko Sawada <msawada@postgresql.org>2025-04-04 10:39:57 -0700
committerMasahiko Sawada <msawada@postgresql.org>2025-04-04 10:39:57 -0700
commitcf2655a9029aff63dd567dbbdcdee15ec969905d (patch)
treef44b8d2018d11e917f59a04f6d122455de9ada95 /src/bin/pg_basebackup/pg_recvlogical.c
parent3556c89321e8baa2242288bd4f015efd1e9d6be0 (diff)
downloadpostgresql-cf2655a9029aff63dd567dbbdcdee15ec969905d.tar.gz
postgresql-cf2655a9029aff63dd567dbbdcdee15ec969905d.zip
pg_recvlogical: Add --failover option.
This new option instructs pg_recvlogical to create the logical replication slot with the failover option enabled. It can be used in conjunction with the --create-slot option. Author: Hayato Kuroda <kuroda.hayato@fujitsu.com> Reviewed-by: Michael Banck <mbanck@gmx.net> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Discussion: https://postgr.es/m/OSCPR01MB14966C54097FC83AF19F3516BF5AC2@OSCPR01MB14966.jpnprd01.prod.outlook.com
Diffstat (limited to 'src/bin/pg_basebackup/pg_recvlogical.c')
-rw-r--r--src/bin/pg_basebackup/pg_recvlogical.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c
index e6158251ec1..e6810efe5f0 100644
--- a/src/bin/pg_basebackup/pg_recvlogical.c
+++ b/src/bin/pg_basebackup/pg_recvlogical.c
@@ -42,6 +42,7 @@ typedef enum
static char *outfile = NULL;
static int verbose = 0;
static bool two_phase = false;
+static bool failover = false;
static int noloop = 0;
static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
static int fsync_interval = 10 * 1000; /* 10 sec = default */
@@ -89,6 +90,8 @@ usage(void)
printf(_(" --start start streaming in a replication slot (for the slot's name see --slot)\n"));
printf(_("\nOptions:\n"));
printf(_(" -E, --endpos=LSN exit after receiving the specified LSN\n"));
+ printf(_(" --failover enable replication slot synchronization to standby servers when\n"
+ " creating a slot\n"));
printf(_(" -f, --file=FILE receive log into this file, - for stdout\n"));
printf(_(" -F --fsync-interval=SECS\n"
" time between fsyncs to the output file (default: %d)\n"), (fsync_interval / 1000));
@@ -695,6 +698,7 @@ main(int argc, char **argv)
{"file", required_argument, NULL, 'f'},
{"fsync-interval", required_argument, NULL, 'F'},
{"no-loop", no_argument, NULL, 'n'},
+ {"failover", no_argument, NULL, 5},
{"verbose", no_argument, NULL, 'v'},
{"two-phase", no_argument, NULL, 't'},
{"version", no_argument, NULL, 'V'},
@@ -770,6 +774,9 @@ main(int argc, char **argv)
case 'v':
verbose++;
break;
+ case 5:
+ failover = true;
+ break;
/* connection options */
case 'd':
dbname = pg_strdup(optarg);
@@ -917,11 +924,21 @@ main(int argc, char **argv)
exit(1);
}
- if (two_phase && !do_create_slot)
+ if (!do_create_slot)
{
- pg_log_error("--two-phase may only be specified with --create-slot");
- pg_log_error_hint("Try \"%s --help\" for more information.", progname);
- exit(1);
+ if (two_phase)
+ {
+ pg_log_error("--two-phase may only be specified with --create-slot");
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
+ exit(1);
+ }
+
+ if (failover)
+ {
+ pg_log_error("--failover may only be specified with --create-slot");
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
+ exit(1);
+ }
}
/*
@@ -984,7 +1001,8 @@ main(int argc, char **argv)
pg_log_info("creating replication slot \"%s\"", replication_slot);
if (!CreateReplicationSlot(conn, replication_slot, plugin, false,
- false, false, slot_exists_ok, two_phase))
+ false, false, slot_exists_ok, two_phase,
+ failover))
exit(1);
startpos = InvalidXLogRecPtr;
}