</listitem>
</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>
<term><option>-P</option></term>
<term><option>--progress</option></term>
'pg_rewind',
"--debug",
"--source-pgdata=$standby_pgdata",
- "--target-pgdata=$master_pgdata"
+ "--target-pgdata=$master_pgdata",
+ "--no-sync"
],
'pg_rewind local');
}
[
'pg_rewind', "--debug",
"--source-server", $standby_connstr,
- "--target-pgdata=$master_pgdata"
+ "--target-pgdata=$master_pgdata",
+ "--no-sync"
],
'pg_rewind remote');
}
bool debug = false;
bool showprogress = false;
bool dry_run = false;
+bool do_sync = true;
/* Target history */
TimeLineHistoryEntry *targetHistory;
printf(_(" --source-pgdata=DIRECTORY source data directory 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, --no-sync do not wait for changes to be written\n"));
+ printf(_(" safely to disk\n"));
printf(_(" -P, --progress write progress messages\n"));
printf(_(" --debug write a lot of debug messages\n"));
printf(_(" -V, --version output version information, then exit\n"));
{"source-server", required_argument, NULL, 2},
{"version", no_argument, NULL, 'V'},
{"dry-run", no_argument, NULL, 'n'},
+ {"no-sync", no_argument, NULL, 'N'},
{"progress", no_argument, NULL, 'P'},
{"debug", no_argument, NULL, 3},
{NULL, 0, NULL, 0}
}
}
- 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)
{
dry_run = true;
break;
+ case 'N':
+ do_sync = false;
+ break;
+
case 3:
debug = true;
break;
static void
syncTargetDirectory(const char *argv0)
{
- if (dry_run)
+ if (!do_sync || dry_run)
return;
fsync_pgdata(datadir_target, progname, PG_VERSION_NUM);