Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f39712

Browse files
committed
pg_receivewal: Add --no-sync option.
Michael Paquier, reviewed by Kuntal Ghosh and by me. I did a littlewordsmithing on the documentation, too.Discussion:http://postgr.es/m/CAB7nPqTuXuyEoVKcWcExh_b0uAjgWd_14KfGLrCTccBZ=VA0KA@mail.gmail.com
1 parentb7f3eb3 commit5f39712

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

‎doc/src/sgml/ref/pg_receivewal.sgml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ PostgreSQL documentation
135135
</listitem>
136136
</varlistentry>
137137

138+
<varlistentry>
139+
<term><option>--no-sync</option></term>
140+
<listitem>
141+
<para>
142+
This option causes <command>pg_receivewal</command> to not force WAL
143+
data to be flushed to disk. This is faster, but means that a
144+
subsequent operating system crash can leave the WAL segments corrupt.
145+
Generally, this option is useful for testing but should not be used
146+
when doing WAL archiving on a production deployment.
147+
</para>
148+
149+
<para>
150+
This option is incompatible with <literal>--synchronous</literal>.
151+
</para>
152+
</listitem>
153+
</varlistentry>
154+
138155
<varlistentry>
139156
<term><option>-s <replaceable class="parameter">interval</replaceable></option></term>
140157
<term><option>--status-interval=<replaceable class="parameter">interval</replaceable></option></term>

‎src/bin/pg_basebackup/pg_receivewal.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static volatile bool time_to_stop = false;
4040
staticbooldo_create_slot= false;
4141
staticboolslot_exists_ok= false;
4242
staticbooldo_drop_slot= false;
43+
staticbooldo_sync= true;
4344
staticboolsynchronous= false;
4445
staticchar*replication_slot=NULL;
4546
staticXLogRecPtrendpos=InvalidXLogRecPtr;
@@ -81,6 +82,7 @@ usage(void)
8182
printf(_(" -E, --endpos=LSN exit after receiving the specified LSN\n"));
8283
printf(_(" --if-not-exists do not error if slot already exists when creating a slot\n"));
8384
printf(_(" -n, --no-loop do not loop on connection lost\n"));
85+
printf(_(" --no-sync do not wait for changes to be written safely to disk\n"));
8486
printf(_(" -s, --status-interval=SECS\n"
8587
" time between status packets sent to server (default: %d)\n"), (standby_message_timeout /1000));
8688
printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
@@ -425,7 +427,7 @@ StreamLog(void)
425427
stream.stop_socket=PGINVALID_SOCKET;
426428
stream.standby_message_timeout=standby_message_timeout;
427429
stream.synchronous=synchronous;
428-
stream.do_sync=true;
430+
stream.do_sync=do_sync;
429431
stream.mark_done= false;
430432
stream.walmethod=CreateWalDirectoryMethod(basedir,compresslevel,
431433
stream.do_sync);
@@ -487,6 +489,7 @@ main(int argc, char **argv)
487489
{"drop-slot",no_argument,NULL,2},
488490
{"if-not-exists",no_argument,NULL,3},
489491
{"synchronous",no_argument,NULL,4},
492+
{"no-sync",no_argument,NULL,5},
490493
{NULL,0,NULL,0}
491494
};
492495

@@ -595,6 +598,9 @@ main(int argc, char **argv)
595598
case4:
596599
synchronous= true;
597600
break;
601+
case5:
602+
do_sync= false;
603+
break;
598604
default:
599605

600606
/*
@@ -637,6 +643,14 @@ main(int argc, char **argv)
637643
exit(1);
638644
}
639645

646+
if (synchronous&& !do_sync)
647+
{
648+
fprintf(stderr,_("%s: cannot use --synchronous together with --no-sync\n"),progname);
649+
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),
650+
progname);
651+
exit(1);
652+
}
653+
640654
/*
641655
* Required arguments
642656
*/

‎src/bin/pg_basebackup/t/020_pg_receivewal.pl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use warnings;
33
use TestLib;
44
use PostgresNode;
5-
use Test::Moretests=>17;
5+
use Test::Moretests=>18;
66

77
program_help_ok('pg_receivewal');
88
program_version_ok('pg_receivewal');
@@ -24,6 +24,9 @@
2424
$primary->command_fails(
2525
['pg_receivewal','-D',$stream_dir,'--create-slot' ],
2626
'failure if --create-slot specified without --slot');
27+
$primary->command_fails(
28+
['pg_receivewal','-D',$stream_dir,'--synchronous','--no-sync' ],
29+
'failure if --synchronous specified with --no-sync');
2730

2831
# Slot creation and drop
2932
my$slot_name ='test';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp