Skip to content

Commit e7c1188

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 01a162e commit e7c1188

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

doc/src/sgml/recovery-config.sgml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
415415
<para>
416416
By default, a standby server restores WAL records from the
417417
primary as soon as possible. It may be useful to have a time-delayed
418-
copy of the data, offering various options to correct data loss errors.
418+
copy of the data, offering opportunities to correct data loss errors.
419419
This parameter allows you to delay recovery by a fixed period of time,
420-
specified in milliseconds if no unit is specified. For example, if
420+
measured in milliseconds if no unit is specified. For example, if
421421
you set this parameter to <literal>5min</literal>, the standby will
422422
replay each transaction commit only when the system time on the standby
423423
is at least five minutes past the commit time reported by the master.
@@ -426,27 +426,26 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
426426
It is possible that the replication delay between servers exceeds the
427427
value of this parameter, in which case no delay is added.
428428
Note that the delay is calculated between the WAL timestamp as written
429-
on master and the time on the current standby. Delays
430-
in transfer because of networks or cascading replication configurations
429+
on master and the current time on the standby. Delays in transfer
430+
because of network lag or cascading replication configurations
431431
may reduce the actual wait time significantly. If the system
432432
clocks on master and standby are not synchronized, this may lead to
433433
recovery applying records earlier than expected; but that is not a
434-
major issue because useful settings of the parameter are much larger
435-
than typical time deviations between servers. Be careful to allow for
436-
different timezone settings on master and standby.
434+
major issue because useful settings of this parameter are much larger
435+
than typical time deviations between servers.
437436
</para>
438437
<para>
439-
The delay occurs only on WAL records for COMMIT and Restore Points.
440-
Other records may be replayed earlier than the specified delay, which
441-
is not an issue for MVCC though it may potentially increase the number
442-
of recovery conflicts generated.
438+
The delay occurs only on WAL records for transaction commits.
439+
Other records are replayed as quickly as possible, which
440+
is not a problem because MVCC visibility rules ensure their effects
441+
are not visible until the corresponding commit record is applied.
443442
</para>
444443
<para>
445444
The delay occurs until the standby is promoted or triggered. After that
446445
the standby will end recovery without further waiting.
447446
</para>
448447
<para>
449-
This parameter is intended for use with streaming replication deployments,
448+
This parameter is intended for use with streaming replication deployments;
450449
however, if the parameter is specified it will be honored in all cases.
451450
Synchronous replication is not affected by this setting because there is
452451
not yet any setting to request synchronous apply of transaction commits.

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5752,7 +5752,7 @@ recoveryApplyDelay(XLogRecord *record)
57525752
int microsecs;
57535753

57545754
/* nothing to do if no delay configured */
5755-
if (recovery_min_apply_delay == 0)
5755+
if (recovery_min_apply_delay <= 0)
57565756
return false;
57575757

57585758
/*

0 commit comments

Comments
 (0)