Re: Recovery to backup point

From: "MauMau" <maumau307(at)gmail(dot)com>
To: "Heikki Linnakangas" <hlinnakangas(at)vmware(dot)com>
Cc: "Michael Paquier" <michael(dot)paquier(at)gmail(dot)com>, "PostgreSQL mailing lists" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Recovery to backup point
Date: 2014-01-09 15:08:03
Message-ID: 90D205C7C6A34D6AA96C31BA06A1B0B4@maumau
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: "Heikki Linnakangas" <hlinnakangas(at)vmware(dot)com>
> 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)
ereport(LOG,
(errmsg("starting point-in-time recovery to XID %u",
recoveryTargetXid)));
+ 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)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -6971,6 +7017,22 @@ StartupXLOG(void)
if (switchedTLI && AllowCascadeReplication())
WalSndWakeup();

+ /*
+ * 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",
recoveryStopXid);
+ 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.
>

Regards
MauMau

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2014-01-09 15:09:44 Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Previous Message Michael Meskes 2014-01-09 15:01:55 Re: [bug fix] ECPG app crashes due to SIGBUS on SPARC Solaris