Thanks for suggestions. Patch updated.
Mon, 22 Dec 2014 12:07:06 +0900 от Michael Paquier <michael.paqu...@gmail.com>: >On Tue, Nov 4, 2014 at 6:25 AM, Alexey Vasiliev < leopard...@inbox.ru > wrote: >> Added new patch. >Seems useful to me to be able to tune this interval of time. > >I would simply reword the documentation as follows: >If <varname>restore_command</> returns nonzero exit status code, retry >command after the interval of time specified by this parameter. >Default value is <literal>5s</>. > >Also, I think that it would be a good idea to error out if this >parameter has a value of let's say, less than 1s instead of doing a >check for a positive value in the waiting latch. On top of that, the >default value of restore_command_retry_interval should be 5000 and not >0 to simplify the code. >-- >Michael > > >-- >Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) >To make changes to your subscription: >http://www.postgresql.org/mailpref/pgsql-hackers -- Alexey Vasiliev
diff --git a/doc/src/sgml/recovery-config.sgml b/doc/src/sgml/recovery-config.sgml index ef78bc0..53ccf13 100644 --- a/doc/src/sgml/recovery-config.sgml +++ b/doc/src/sgml/recovery-config.sgml @@ -145,6 +145,29 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows </listitem> </varlistentry> + <varlistentry id="restore-command-retry-interval" xreflabel="restore_command_retry_interval"> + <term><varname>restore_command_retry_interval</varname> (<type>integer</type>) + <indexterm> + <primary><varname>restore_command_retry_interval</> recovery parameter</primary> + </indexterm> + </term> + <listitem> + <para> + If <varname>restore_command</> returns nonzero exit status code, retry + command after the interval of time specified by this parameter. + Default value is <literal>5s</>. + </para> + <para> + This is useful, if I using for restore of wal logs some + external storage (like AWS S3) and no matter what the slave database + will lag behind the master. The problem, what for each request to + AWS S3 need to pay, what is why for N nodes, which try to get next + wal log each 5 seconds will be bigger price, than for example each + 30 seconds. + </para> + </listitem> + </varlistentry> + </variablelist> </sect1> diff --git a/src/backend/access/transam/recovery.conf.sample b/src/backend/access/transam/recovery.conf.sample index b777400..7ed6f3b 100644 --- a/src/backend/access/transam/recovery.conf.sample +++ b/src/backend/access/transam/recovery.conf.sample @@ -58,6 +58,11 @@ # #recovery_end_command = '' # +# specifies an optional timeout after nonzero code of restore_command. +# This can be useful to increase/decrease number of a restore_command calls. +# +#restore_command_retry_interval = 5s +# #--------------------------------------------------------------------------- # RECOVERY TARGET PARAMETERS #--------------------------------------------------------------------------- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index e5dddd4..02c55a8 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -235,6 +235,7 @@ static TimestampTz recoveryTargetTime; static char *recoveryTargetName; static int recovery_min_apply_delay = 0; static TimestampTz recoveryDelayUntilTime; +static int restore_command_retry_interval = 5000L; /* options taken from recovery.conf for XLOG streaming */ static bool StandbyModeRequested = false; @@ -4881,6 +4882,28 @@ readRecoveryCommandFile(void) (errmsg_internal("trigger_file = '%s'", TriggerFile))); } + else if (strcmp(item->name, "restore_command_retry_interval") == 0) + { + const char *hintmsg; + + if (!parse_int(item->value, &restore_command_retry_interval, GUC_UNIT_MS, + &hintmsg)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("parameter \"%s\" requires a temporal value", + "restore_command_retry_interval"), + hintmsg ? errhint("%s", _(hintmsg)) : 0)); + ereport(DEBUG2, + (errmsg_internal("restore_command_retry_interval = '%s'", item->value))); + + if (restore_command_retry_interval <= 0) + { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("\"%s\" must be bigger zero", + "restore_command_retry_interval"))); + } + } else if (strcmp(item->name, "recovery_min_apply_delay") == 0) { const char *hintmsg; @@ -10658,13 +10681,14 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, } /* - * Wait for more WAL to arrive. Time out after 5 seconds, + * Wait for more WAL to arrive. Time out after + * restore_command_retry_interval (5 seconds by default), * like when polling the archive, to react to a trigger * file promptly. */ WaitLatch(&XLogCtl->recoveryWakeupLatch, WL_LATCH_SET | WL_TIMEOUT, - 5000L); + restore_command_retry_interval); ResetLatch(&XLogCtl->recoveryWakeupLatch); break; }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers