mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-24 07:36:30 +00:00
Support --fast-checkpoint
This commit is contained in:
10
dbutils.c
10
dbutils.c
@@ -827,15 +827,15 @@ create_replication_slot(PGconn *conn, char *slot_name)
|
||||
|
||||
|
||||
bool
|
||||
start_backup(PGconn *conn, char *first_wal_segment)
|
||||
start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint)
|
||||
{
|
||||
char sqlquery[QUERY_STR_LEN];
|
||||
PGresult *res;
|
||||
|
||||
sqlquery_snprintf(
|
||||
sqlquery,
|
||||
"SELECT pg_xlogfile_name(pg_start_backup('repmgr_standby_clone_%ld'))",
|
||||
time(NULL));
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"SELECT pg_xlogfile_name(pg_start_backup('repmgr_standby_clone_%ld', %s))",
|
||||
time(NULL),
|
||||
fast_checkpoint ? "TRUE" : "FALSE");
|
||||
|
||||
log_debug(_("standby clone: %s\n"), sqlquery);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ char *get_repmgr_schema(void);
|
||||
char *get_repmgr_schema_quoted(PGconn *conn);
|
||||
bool create_replication_slot(PGconn *conn, char *slot_name);
|
||||
|
||||
bool start_backup(PGconn *conn, char *first_wal_segment);
|
||||
bool start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint);
|
||||
bool stop_backup(PGconn *conn, char *last_wal_segment);
|
||||
bool set_config_bool(PGconn *conn, const char *config_param, bool state);
|
||||
bool copy_configuration(PGconn *masterconn, PGconn *witnessconn, char *cluster_name);
|
||||
|
||||
38
repmgr.c
38
repmgr.c
@@ -142,6 +142,7 @@ main(int argc, char **argv)
|
||||
{"initdb-no-pwprompt", no_argument, NULL, 1},
|
||||
{"check-upstream-config", no_argument, NULL, 2},
|
||||
{"rsync-only", no_argument, NULL, 3},
|
||||
{"fast-checkpoint", no_argument, NULL, 4},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -264,6 +265,9 @@ main(int argc, char **argv)
|
||||
case 3:
|
||||
runtime_options.rsync_only = true;
|
||||
break;
|
||||
case 4:
|
||||
runtime_options.fast_checkpoint = true;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
PQExpBufferData unknown_option;
|
||||
@@ -1169,7 +1173,7 @@ do_standby_clone(void)
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
if(start_backup(upstream_conn, first_wal_segment) == false)
|
||||
if(start_backup(upstream_conn, first_wal_segment, runtime_options.fast_checkpoint) == false)
|
||||
{
|
||||
r = ERR_BAD_BASEBACKUP;
|
||||
retval = ERR_BAD_BASEBACKUP;
|
||||
@@ -1477,7 +1481,6 @@ stop_backup:
|
||||
log_notice(_("standby clone (using pg_basebackup) complete\n"));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX It might be nice to provide the following options:
|
||||
* - have repmgr start the daemon automatically
|
||||
@@ -2226,7 +2229,8 @@ help(const char *progname)
|
||||
" to happen\n"));
|
||||
printf(_(" -W, --wait wait for a master to appear\n"));
|
||||
printf(_(" -r, --min-recovery-apply-delay=VALUE enable recovery time delay, value has to be a valid time atom (e.g. 5min)\n"));
|
||||
printf(_(" --rsync-only use only rsync to make the initial base backup\n"));
|
||||
printf(_(" --rsync-only use only rsync to clone a standby\n"));
|
||||
printf(_(" --fast-checkpoint force fast checkpoint when cloning a standby\n"));
|
||||
printf(_(" --initdb-no-pwprompt don't require superuser password when running initdb\n"));
|
||||
printf(_(" --check-upstream-config verify upstream server configuration\n"));
|
||||
printf(_("\n%s performs the following node management tasks:\n\n"), progname);
|
||||
@@ -2476,16 +2480,28 @@ run_basebackup()
|
||||
initPQExpBuffer(¶ms);
|
||||
|
||||
if(strlen(runtime_options.host))
|
||||
{
|
||||
appendPQExpBuffer(¶ms, " -h %s", runtime_options.host);
|
||||
}
|
||||
|
||||
if(strlen(runtime_options.masterport))
|
||||
{
|
||||
appendPQExpBuffer(¶ms, " -p %s", runtime_options.masterport);
|
||||
}
|
||||
|
||||
if(strlen(runtime_options.username))
|
||||
{
|
||||
appendPQExpBuffer(¶ms, " -U %s", runtime_options.username);
|
||||
}
|
||||
|
||||
if(strlen(runtime_options.dest_dir))
|
||||
{
|
||||
appendPQExpBuffer(¶ms, " -D %s", runtime_options.dest_dir);
|
||||
}
|
||||
|
||||
if(runtime_options.fast_checkpoint) {
|
||||
appendPQExpBuffer(¶ms, " -c fast");
|
||||
}
|
||||
|
||||
if(options.tablespace_mapping.head != NULL)
|
||||
{
|
||||
@@ -2499,15 +2515,14 @@ run_basebackup()
|
||||
"%s -l \"repmgr base backup\" %s %s",
|
||||
make_pg_path("pg_basebackup"),
|
||||
params.data,
|
||||
options.pg_basebackup_options
|
||||
);
|
||||
options.pg_basebackup_options);
|
||||
|
||||
termPQExpBuffer(¶ms);
|
||||
|
||||
log_info(_("executing: '%s'\n"), script);
|
||||
|
||||
/*
|
||||
* As of 9.4, pg_basebackup et al only ever return 0 or 1
|
||||
* As of 9.4, pg_basebackup only ever returns 0 or 1
|
||||
*/
|
||||
|
||||
r = system(script);
|
||||
@@ -2517,7 +2532,8 @@ run_basebackup()
|
||||
|
||||
|
||||
/*
|
||||
* Tries to avoid useless or conflicting parameters
|
||||
* Check for useless or conflicting parameters, and also whether a
|
||||
* configuration file is required.
|
||||
*/
|
||||
static void
|
||||
check_parameters_for_action(const int action)
|
||||
@@ -2634,13 +2650,19 @@ check_parameters_for_action(const int action)
|
||||
{
|
||||
if(runtime_options.rsync_only)
|
||||
{
|
||||
error_list_append(_("--rsync-only can only be used when executing STANDBY CLONE."));
|
||||
error_list_append(_("--rsync-only can only be used when executing STANDBY CLONE"));
|
||||
}
|
||||
|
||||
if(runtime_options.fast_checkpoint)
|
||||
{
|
||||
error_list_append(_("--fast-checkpoint can only be used when executing STANDBY CLONE"));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
create_schema(PGconn *conn)
|
||||
{
|
||||
|
||||
3
repmgr.h
3
repmgr.h
@@ -80,6 +80,7 @@ typedef struct
|
||||
bool ignore_rsync_warn;
|
||||
bool initdb_no_pwprompt;
|
||||
bool rsync_only;
|
||||
bool fast_checkpoint;
|
||||
|
||||
char masterport[MAXLEN];
|
||||
char localport[MAXLEN];
|
||||
@@ -92,7 +93,7 @@ typedef struct
|
||||
char min_recovery_apply_delay[MAXLEN];
|
||||
} t_runtime_options;
|
||||
|
||||
#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, "", "", 0, "", "" }
|
||||
#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, false, "", "", 0, "", "" }
|
||||
|
||||
extern char repmgr_schema[MAXLEN];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user