mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
pg_receivewal: Add --no-sync option.
Michael Paquier, reviewed by Kuntal Ghosh and by me. I did a little wordsmithing on the documentation, too. Discussion: http://postgr.es/m/CAB7nPqTuXuyEoVKcWcExh_b0uAjgWd_14KfGLrCTccBZ=VA0KA@mail.gmail.com
This commit is contained in:
@ -135,6 +135,23 @@ PostgreSQL documentation
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--no-sync</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
This option causes <command>pg_receivewal</command> to not force WAL
|
||||||
|
data to be flushed to disk. This is faster, but means that a
|
||||||
|
subsequent operating system crash can leave the WAL segments corrupt.
|
||||||
|
Generally, this option is useful for testing but should not be used
|
||||||
|
when doing WAL archiving on a production deployment.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This option is incompatible with <literal>--synchronous</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-s <replaceable class="parameter">interval</replaceable></option></term>
|
<term><option>-s <replaceable class="parameter">interval</replaceable></option></term>
|
||||||
<term><option>--status-interval=<replaceable class="parameter">interval</replaceable></option></term>
|
<term><option>--status-interval=<replaceable class="parameter">interval</replaceable></option></term>
|
||||||
|
@ -40,6 +40,7 @@ static volatile bool time_to_stop = false;
|
|||||||
static bool do_create_slot = false;
|
static bool do_create_slot = false;
|
||||||
static bool slot_exists_ok = false;
|
static bool slot_exists_ok = false;
|
||||||
static bool do_drop_slot = false;
|
static bool do_drop_slot = false;
|
||||||
|
static bool do_sync = true;
|
||||||
static bool synchronous = false;
|
static bool synchronous = false;
|
||||||
static char *replication_slot = NULL;
|
static char *replication_slot = NULL;
|
||||||
static XLogRecPtr endpos = InvalidXLogRecPtr;
|
static XLogRecPtr endpos = InvalidXLogRecPtr;
|
||||||
@ -81,6 +82,7 @@ usage(void)
|
|||||||
printf(_(" -E, --endpos=LSN exit after receiving the specified LSN\n"));
|
printf(_(" -E, --endpos=LSN exit after receiving the specified LSN\n"));
|
||||||
printf(_(" --if-not-exists do not error if slot already exists when creating a slot\n"));
|
printf(_(" --if-not-exists do not error if slot already exists when creating a slot\n"));
|
||||||
printf(_(" -n, --no-loop do not loop on connection lost\n"));
|
printf(_(" -n, --no-loop do not loop on connection lost\n"));
|
||||||
|
printf(_(" --no-sync do not wait for changes to be written safely to disk\n"));
|
||||||
printf(_(" -s, --status-interval=SECS\n"
|
printf(_(" -s, --status-interval=SECS\n"
|
||||||
" time between status packets sent to server (default: %d)\n"), (standby_message_timeout / 1000));
|
" time between status packets sent to server (default: %d)\n"), (standby_message_timeout / 1000));
|
||||||
printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
|
printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
|
||||||
@ -425,7 +427,7 @@ StreamLog(void)
|
|||||||
stream.stop_socket = PGINVALID_SOCKET;
|
stream.stop_socket = PGINVALID_SOCKET;
|
||||||
stream.standby_message_timeout = standby_message_timeout;
|
stream.standby_message_timeout = standby_message_timeout;
|
||||||
stream.synchronous = synchronous;
|
stream.synchronous = synchronous;
|
||||||
stream.do_sync = true;
|
stream.do_sync = do_sync;
|
||||||
stream.mark_done = false;
|
stream.mark_done = false;
|
||||||
stream.walmethod = CreateWalDirectoryMethod(basedir, compresslevel,
|
stream.walmethod = CreateWalDirectoryMethod(basedir, compresslevel,
|
||||||
stream.do_sync);
|
stream.do_sync);
|
||||||
@ -487,6 +489,7 @@ main(int argc, char **argv)
|
|||||||
{"drop-slot", no_argument, NULL, 2},
|
{"drop-slot", no_argument, NULL, 2},
|
||||||
{"if-not-exists", no_argument, NULL, 3},
|
{"if-not-exists", no_argument, NULL, 3},
|
||||||
{"synchronous", no_argument, NULL, 4},
|
{"synchronous", no_argument, NULL, 4},
|
||||||
|
{"no-sync", no_argument, NULL, 5},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -595,6 +598,9 @@ main(int argc, char **argv)
|
|||||||
case 4:
|
case 4:
|
||||||
synchronous = true;
|
synchronous = true;
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
do_sync = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -637,6 +643,14 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (synchronous && !do_sync)
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("%s: cannot use --synchronous together with --no-sync\n"), progname);
|
||||||
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
|
||||||
|
progname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Required arguments
|
* Required arguments
|
||||||
*/
|
*/
|
||||||
|
@ -2,7 +2,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use TestLib;
|
use TestLib;
|
||||||
use PostgresNode;
|
use PostgresNode;
|
||||||
use Test::More tests => 17;
|
use Test::More tests => 18;
|
||||||
|
|
||||||
program_help_ok('pg_receivewal');
|
program_help_ok('pg_receivewal');
|
||||||
program_version_ok('pg_receivewal');
|
program_version_ok('pg_receivewal');
|
||||||
@ -24,6 +24,9 @@ $primary->command_fails(
|
|||||||
$primary->command_fails(
|
$primary->command_fails(
|
||||||
[ 'pg_receivewal', '-D', $stream_dir, '--create-slot' ],
|
[ 'pg_receivewal', '-D', $stream_dir, '--create-slot' ],
|
||||||
'failure if --create-slot specified without --slot');
|
'failure if --create-slot specified without --slot');
|
||||||
|
$primary->command_fails(
|
||||||
|
[ 'pg_receivewal', '-D', $stream_dir, '--synchronous', '--no-sync' ],
|
||||||
|
'failure if --synchronous specified with --no-sync');
|
||||||
|
|
||||||
# Slot creation and drop
|
# Slot creation and drop
|
||||||
my $slot_name = 'test';
|
my $slot_name = 'test';
|
||||||
|
Reference in New Issue
Block a user