mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 17:51:20 +02:00
Add pg_rewind --no-sync
This is an option consistent with what pg_dump and pg_basebackup provide which is useful for leveraging the I/O effort when testing things, not to be used in a production environment. Author: Michael Paquier Reviewed-by: Heikki Linnakangas Discussion: https://postgr.es/m/20180325122607.GB3707@paquier.xyz
This commit is contained in:
parent
9a4059d4ff
commit
8a00b96aa9
@ -171,6 +171,22 @@ PostgreSQL documentation
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-N</option></term>
|
||||||
|
<term><option>--no-sync</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
By default, <command>pg_rewind</command> will wait for all files
|
||||||
|
to be written safely to disk. This option causes
|
||||||
|
<command>pg_rewind</command> to return without waiting, which is
|
||||||
|
faster, but means that a subsequent operating system crash can leave
|
||||||
|
the synchronized data folder corrupt. Generally, this option is
|
||||||
|
useful for testing but should not be used when creating a production
|
||||||
|
installation.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-P</option></term>
|
<term><option>-P</option></term>
|
||||||
<term><option>--progress</option></term>
|
<term><option>--progress</option></term>
|
||||||
|
@ -231,7 +231,8 @@ sub run_pg_rewind
|
|||||||
'pg_rewind',
|
'pg_rewind',
|
||||||
"--debug",
|
"--debug",
|
||||||
"--source-pgdata=$standby_pgdata",
|
"--source-pgdata=$standby_pgdata",
|
||||||
"--target-pgdata=$master_pgdata"
|
"--target-pgdata=$master_pgdata",
|
||||||
|
"--no-sync"
|
||||||
],
|
],
|
||||||
'pg_rewind local');
|
'pg_rewind local');
|
||||||
}
|
}
|
||||||
@ -243,7 +244,8 @@ sub run_pg_rewind
|
|||||||
[
|
[
|
||||||
'pg_rewind', "--debug",
|
'pg_rewind', "--debug",
|
||||||
"--source-server", $standby_connstr,
|
"--source-server", $standby_connstr,
|
||||||
"--target-pgdata=$master_pgdata"
|
"--target-pgdata=$master_pgdata",
|
||||||
|
"--no-sync"
|
||||||
],
|
],
|
||||||
'pg_rewind remote');
|
'pg_rewind remote');
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ char *connstr_source = NULL;
|
|||||||
bool debug = false;
|
bool debug = false;
|
||||||
bool showprogress = false;
|
bool showprogress = false;
|
||||||
bool dry_run = false;
|
bool dry_run = false;
|
||||||
|
bool do_sync = true;
|
||||||
|
|
||||||
/* Target history */
|
/* Target history */
|
||||||
TimeLineHistoryEntry *targetHistory;
|
TimeLineHistoryEntry *targetHistory;
|
||||||
@ -71,6 +72,8 @@ usage(const char *progname)
|
|||||||
printf(_(" --source-pgdata=DIRECTORY source data directory to synchronize with\n"));
|
printf(_(" --source-pgdata=DIRECTORY source data directory to synchronize with\n"));
|
||||||
printf(_(" --source-server=CONNSTR source server to synchronize with\n"));
|
printf(_(" --source-server=CONNSTR source server to synchronize with\n"));
|
||||||
printf(_(" -n, --dry-run stop before modifying anything\n"));
|
printf(_(" -n, --dry-run stop before modifying anything\n"));
|
||||||
|
printf(_(" -N, --no-sync do not wait for changes to be written\n"));
|
||||||
|
printf(_(" safely to disk\n"));
|
||||||
printf(_(" -P, --progress write progress messages\n"));
|
printf(_(" -P, --progress write progress messages\n"));
|
||||||
printf(_(" --debug write a lot of debug messages\n"));
|
printf(_(" --debug write a lot of debug messages\n"));
|
||||||
printf(_(" -V, --version output version information, then exit\n"));
|
printf(_(" -V, --version output version information, then exit\n"));
|
||||||
@ -89,6 +92,7 @@ main(int argc, char **argv)
|
|||||||
{"source-server", required_argument, NULL, 2},
|
{"source-server", required_argument, NULL, 2},
|
||||||
{"version", no_argument, NULL, 'V'},
|
{"version", no_argument, NULL, 'V'},
|
||||||
{"dry-run", no_argument, NULL, 'n'},
|
{"dry-run", no_argument, NULL, 'n'},
|
||||||
|
{"no-sync", no_argument, NULL, 'N'},
|
||||||
{"progress", no_argument, NULL, 'P'},
|
{"progress", no_argument, NULL, 'P'},
|
||||||
{"debug", no_argument, NULL, 3},
|
{"debug", no_argument, NULL, 3},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
@ -125,7 +129,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "D:nP", long_options, &option_index)) != -1)
|
while ((c = getopt_long(argc, argv, "D:nNP", long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@ -141,6 +145,10 @@ main(int argc, char **argv)
|
|||||||
dry_run = true;
|
dry_run = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'N':
|
||||||
|
do_sync = false;
|
||||||
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
debug = true;
|
debug = true;
|
||||||
break;
|
break;
|
||||||
@ -709,7 +717,7 @@ updateControlFile(ControlFileData *ControlFile)
|
|||||||
static void
|
static void
|
||||||
syncTargetDirectory(const char *argv0)
|
syncTargetDirectory(const char *argv0)
|
||||||
{
|
{
|
||||||
if (dry_run)
|
if (!do_sync || dry_run)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fsync_pgdata(datadir_target, progname, PG_VERSION_NUM);
|
fsync_pgdata(datadir_target, progname, PG_VERSION_NUM);
|
||||||
|
Loading…
Reference in New Issue
Block a user