Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d6657d2

Browse files
committed
Treat negative values of recovery_min_apply_delay as having no effect.
At one point in the development of this feature, it was claimed that allowing negative values would be useful to compensate for timezone differences between master and slave servers. That was based on a mistaken assumption that commit timestamps are recorded in local time; but of course they're in UTC. Nor is a negative apply delay likely to be a sane way of coping with server clock skew. However, the committed patch still treated negative delays as doing something, and the timezone misapprehension survived in the user documentation as well. If recovery_min_apply_delay were a proper GUC we'd just set the minimum allowed value to be zero; but for the moment it seems better to treat negative settings as if they were zero. In passing do some extra wordsmithing on the parameter's documentation, including correcting a second misstatement that the parameter affects processing of Restore Point records. Issue noted by Michael Paquier, who also provided the code patch; doc changes by me. Back-patch to 9.4 where the feature was introduced.
1 parent f9769c7 commit d6657d2

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

doc/src/sgml/recovery-config.sgml

+11-12
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,9 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
458458
<para>
459459
By default, a standby server restores WAL records from the
460460
primary as soon as possible. It may be useful to have a time-delayed
461-
copy of the data, offering various options to correct data loss errors.
461+
copy of the data, offering opportunities to correct data loss errors.
462462
This parameter allows you to delay recovery by a fixed period of time,
463-
specified in milliseconds if no unit is specified. For example, if
463+
measured in milliseconds if no unit is specified. For example, if
464464
you set this parameter to <literal>5min</literal>, the standby will
465465
replay each transaction commit only when the system time on the standby
466466
is at least five minutes past the commit time reported by the master.
@@ -469,27 +469,26 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
469469
It is possible that the replication delay between servers exceeds the
470470
value of this parameter, in which case no delay is added.
471471
Note that the delay is calculated between the WAL timestamp as written
472-
on master and the time on the current standby. Delays
473-
in transfer because of networks or cascading replication configurations
472+
on master and the current time on the standby. Delays in transfer
473+
because of network lag or cascading replication configurations
474474
may reduce the actual wait time significantly. If the system
475475
clocks on master and standby are not synchronized, this may lead to
476476
recovery applying records earlier than expected; but that is not a
477-
major issue because useful settings of the parameter are much larger
478-
than typical time deviations between servers. Be careful to allow for
479-
different timezone settings on master and standby.
477+
major issue because useful settings of this parameter are much larger
478+
than typical time deviations between servers.
480479
</para>
481480
<para>
482-
The delay occurs only on WAL records for COMMIT and Restore Points.
483-
Other records may be replayed earlier than the specified delay, which
484-
is not an issue for MVCC though it may potentially increase the number
485-
of recovery conflicts generated.
481+
The delay occurs only on WAL records for transaction commits.
482+
Other records are replayed as quickly as possible, which
483+
is not a problem because MVCC visibility rules ensure their effects
484+
are not visible until the corresponding commit record is applied.
486485
</para>
487486
<para>
488487
The delay occurs until the standby is promoted or triggered. After that
489488
the standby will end recovery without further waiting.
490489
</para>
491490
<para>
492-
This parameter is intended for use with streaming replication deployments,
491+
This parameter is intended for use with streaming replication deployments;
493492
however, if the parameter is specified it will be honored in all cases.
494493
Synchronous replication is not affected by this setting because there is
495494
not yet any setting to request synchronous apply of transaction commits.

src/backend/access/transam/xlog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5430,7 +5430,7 @@ recoveryApplyDelay(XLogReaderState *record)
54305430
int microsecs;
54315431

54325432
/* nothing to do if no delay configured */
5433-
if (recovery_min_apply_delay == 0)
5433+
if (recovery_min_apply_delay <= 0)
54345434
return false;
54355435

54365436
/*

0 commit comments

Comments
 (0)