From: "Heikki Linnakangas" <>
After some refactoring and fixing bugs in the existing code, I came up
with the attached patch. I called the option simply "recovery_target",
with the only allowed value of "immediate". IOW, if you want to stop
recovery as early as possible, you add recovery_target='immediate' to
recovery.conf. Now that we have four different options to set the
recovery target with, I rearranged the docs slightly. How does this look
to you?

I'm almost comfortable with your patch.  There are two comments:

C1. The following parts seem to be mistakenly taken from my patch. These are not necessary for your patch, aren't they?

@@ -6238,6 +6277,10 @@ StartupXLOG(void)
     (errmsg("starting point-in-time recovery to XID %u",
+  else if (recoveryTarget == RECOVERY_TARGET_TIME &&
+   recoveryTargetTime == 0)
+   ereport(LOG,
+     (errmsg("starting point-in-time recovery to backup point")));
  else if (recoveryTarget == RECOVERY_TARGET_TIME)
     (errmsg("starting point-in-time recovery to %s",
@@ -6971,6 +7017,22 @@ StartupXLOG(void)
    if (switchedTLI && AllowCascadeReplication())

+    /*
+     * If we have reached the end of base backup during recovery
+     * to the backup point, exit redo loop.
+     */
+    if (recoveryTarget == RECOVERY_TARGET_TIME &&
+     recoveryTargetTime == 0 && reachedConsistency)
+    {
+     if (recoveryPauseAtTarget)
+     {
+      SetRecoveryPause(true);
+      recoveryPausesHere();
+     }
+     reachedStopPoint = true;
+     break;
+    }
    /* Exit loop if we reached inclusive recovery target */
    if (recoveryStopsAfter(record))
@@ -7116,6 +7178,9 @@ StartupXLOG(void)
      "%s transaction %u",
      recoveryStopAfter ? "after" : "before",
+  else if (recoveryTarget == RECOVERY_TARGET_TIME &&
+   recoveryStopTime == 0)
+   snprintf(reason, sizeof(reason), "at backup point");
  else if (recoveryTarget == RECOVERY_TARGET_TIME)
   snprintf(reason, sizeof(reason),
      "%s %s\n",

C2. "recovery_target = 'immediate'" sounds less intuitive than my suggestion "recovery_target_time = 'backup_point'", at least for those who want to recover to the backup point. Although I don't have a good naming sense in English, the value should be a noun, not an adjective like "immediate", because the value specifies the "target (point)" of recovery.

Being related to C2, I wonder if users would understand the following part in the documentation.

+        This parameter specifies that recovery should end as soon as a
+        consistency is reached, ie. as early as possible.

The subsequent sentence clarifies the use case for recovery from an online backup, but in what use cases do they specify this parameter? For example, when do the users face the following situation?

I was thinking that you have a warm standby server, and you decide to
stop using it as a warm standby, and promote it. You'd do that by
stopping it, modifying recovery.conf to remove standby_mode, and set a
recovery target, and then restart.


Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to