From a9613ee692463c6ff061227c3ca63075ea1f10f1 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Sun, 6 Mar 2016 02:29:04 +0900 Subject: 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 --- src/backend/access/transam/xlog.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index cc845d23e20..7d23d8e21c6 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5856,6 +5856,10 @@ recoveryApplyDelay(XLogRecord *record) if (recovery_min_apply_delay <= 0) return false; + /* no delay is applied on a database not yet consistent */ + if (!reachedConsistency) + return false; + /* * Is it a COMMIT record? * -- cgit v1.2.3