Skip to content

Commit a9613ee

Browse files
committed
Ignore recovery_min_apply_delay until recovery has reached consistent state
Previously recovery_min_apply_delay was applied even before recovery had reached consistency. This could cause us to wait a long time unexpectedly for read-only connections to be allowed. It's problematic because the standby was useless during that wait time. This patch changes recovery_min_apply_delay so that it's applied once the database has reached the consistent state. That is, even if the delay is set, the standby tries to replay WAL records as fast as possible until it has reached consistency. Author: Michael Paquier Reviewed-By: Julien Rouhaud Reported-By: Greg Clough Backpatch: 9.4, where recovery_min_apply_delay was added Bug: #13770 Discussion: http://www.postgresql.org/message-id/20151111155006.2644.84564@wrigleys.postgresql.org
1 parent 2105091 commit a9613ee

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

doc/src/sgml/recovery-config.sgml

+3-2
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,9 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
441441
are not visible until the corresponding commit record is applied.
442442
</para>
443443
<para>
444-
The delay occurs until the standby is promoted or triggered. After that
445-
the standby will end recovery without further waiting.
444+
The delay occurs once the database in recovery has reached a consistent
445+
state, until the standby is promoted or triggered. After that the standby
446+
will end recovery without further waiting.
446447
</para>
447448
<para>
448449
This parameter is intended for use with streaming replication deployments;

src/backend/access/transam/xlog.c

+4
Original file line numberDiff line numberDiff line change
@@ -5856,6 +5856,10 @@ recoveryApplyDelay(XLogRecord *record)
58565856
if (recovery_min_apply_delay <= 0)
58575857
return false;
58585858

5859+
/* no delay is applied on a database not yet consistent */
5860+
if (!reachedConsistency)
5861+
return false;
5862+
58595863
/*
58605864
* Is it a COMMIT record?
58615865
*

0 commit comments

Comments
 (0)