20160102_recovery_delay_consistent.patch
text/x-patch
Filename: 20160102_recovery_delay_consistent.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| doc/src/sgml/recovery-config.sgml | 3 | 2 |
| src/backend/access/transam/xlog.c | 4 | 0 |
diff --git a/doc/src/sgml/recovery-config.sgml b/doc/src/sgml/recovery-config.sgml
index 22d1332..26af221 100644
--- a/doc/src/sgml/recovery-config.sgml
+++ b/doc/src/sgml/recovery-config.sgml
@@ -462,8 +462,9 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
are not visible until the corresponding commit record is applied.
</para>
<para>
- The delay occurs until the standby is promoted or triggered. After that
- the standby will end recovery without further waiting.
+ The delay occurs once the database in recovery has reached a consistent
+ state, until the standby is promoted or triggered. After that the standby
+ will end recovery without further waiting.
</para>
<para>
This parameter is intended for use with streaming replication deployments;
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index ce2e074..1abead5 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -5668,6 +5668,10 @@ recoveryApplyDelay(XLogReaderState *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?
*