From 196585c78afb242366f05d69d2c5d77bc141699c Mon Sep 17 00:00:00 2001 From: Christoph Monech-Tegeder Date: Wed, 8 Apr 2015 23:07:03 +0200 Subject: [PATCH] optional fast checkpointing commandline -X/--fast-checkpoint --- HISTORY | 1 + repmgr.c | 12 +++++++++--- repmgr.h | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/HISTORY b/HISTORY index b191f808..e42067ef 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ 2.0.3 2015-??-?? Add option "--initdb-no-pwprompt" (Ian) Add -S/--superuser option for witness database creation Ian) + Add -X/--fast-checkpoint option for cloning (Christoph) 2.0.2 2015-02-17 Add "--checksum" in rsync when using "--force" (Jaime) diff --git a/repmgr.c b/repmgr.c index b85a0a58..c02709e6 100644 --- a/repmgr.c +++ b/repmgr.c @@ -110,6 +110,7 @@ main(int argc, char **argv) {"wait", no_argument, NULL, 'W'}, {"ignore-rsync-warning", no_argument, NULL, 'I'}, {"verbose", no_argument, NULL, 'v'}, + {"fast-checkpoint", no_argument, NULL, 'X'}, {NULL, 0, NULL, 0} }; @@ -134,7 +135,7 @@ main(int argc, char **argv) } - while ((c = getopt_long(argc, argv, "d:h:p:U:D:l:f:R:w:k:FWIv", long_options, + while ((c = getopt_long(argc, argv, "d:h:p:U:D:l:f:R:w:k:FWIvX", long_options, &optindex)) != -1) { switch (c) @@ -187,6 +188,9 @@ main(int argc, char **argv) case 'v': runtime_options.verbose = true; break; + case 'X': + runtime_options.fast_checkpoint = true; + break; default: usage(); exit(ERR_BAD_CONFIG); @@ -1106,8 +1110,9 @@ do_standby_clone(void) */ sqlquery_snprintf( sqlquery, - "SELECT pg_xlogfile_name(pg_start_backup('repmgr_standby_clone_%ld'))", - time(NULL)); + "SELECT pg_xlogfile_name(pg_start_backup('repmgr_standby_clone_%ld', '%c'))", + time(NULL), + runtime_options.fast_checkpoint ? 't' : 'f'); log_debug(_("standby clone: %s\n"), sqlquery); res = PQexec(conn, sqlquery); if (PQresultStatus(res) != PGRES_TUPLES_OK) @@ -1944,6 +1949,7 @@ help(const char *progname) printf(_(" -F, --force force potentially dangerous operations\n" \ " to happen\n")); printf(_(" -W, --wait wait for a master to appear\n")); + printf(_(" -X, --fast-checkpoint force immediate checkpoint when cloning\n")); printf(_("\n%s performs some tasks like clone a node, promote it or making follow\n"), progname); printf(_("another node and then exits.\n\n")); diff --git a/repmgr.h b/repmgr.h index ff1aa2ee..01001c4e 100644 --- a/repmgr.h +++ b/repmgr.h @@ -61,6 +61,7 @@ typedef struct bool force; bool wait_for_master; bool ignore_rsync_warn; + bool fast_checkpoint; char masterport[MAXLEN]; char localport[MAXLEN]; @@ -69,6 +70,6 @@ typedef struct int keep_history; } t_runtime_options; -#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 } +#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, "", "", 0 } #endif