Recovery Target Settings
+ By default, recovery will recover to the end of the WAL log. The
+ following parameters can be used to specify an earlier stopping point.
+ At most one of recovery_target>,
+ recovery_target_name>, recovery_target_time>, or
+ recovery_target_xid> can be specified.
+
+
+ recovery_target = 'immediate'
+
+
recovery_target> recovery parameter
+
+
+ This parameter specifies that recovery should end as soon as a
+ consistency is reached, ie. as early as possible. When restoring from an
+ online backup, this means the point where taking the backup ended.
+
+ Technically, this is a string parameter, but 'immediate'>
+ is currently the only allowed value.
+
+
+
+
recovery_target_name
(string)
This parameter specifies the named restore point, created with
pg_create_restore_point()> to which recovery will proceed.
- At most one of recovery_target_name>,
- or
- can be specified. The default is to
- recover to the end of the WAL log.
This parameter specifies the time stamp up to which recovery
will proceed.
- At most one of recovery_target_time>,
- or
- can be specified.
- The default is to recover to the end of the WAL log.
The precise stopping point is also influenced by
.
start, transactions can complete in a different numeric order.
The transactions that will be recovered are those that committed
before (and optionally including) the specified one.
- At most one of recovery_target_xid>,
- or
- can be specified.
- The default is to recover to the end of the WAL log.
The precise stopping point is also influenced by
.
+
+ The following options further specify the recovery target, and affect
+ what happens when the target is reached:
+
+
+
xreflabel="recovery_target_inclusive">
#recovery_target_inclusive = true
#
#
+# Alternatively, you can request stopping as soon as a consistent state
+# is reached, by uncommenting this option.
+#
+#recovery_target = 'immediate'
+#
+#
# If you want to recover into a timeline other than the "main line" shown in
# pg_control, specify the timeline number here, or write 'latest' to get
# the latest branch for which there's a history file.
(errmsg_internal("recovery_target_name = '%s'",
recoveryTargetName)));
}
+ else if (strcmp(item->name, "recovery_target") == 0)
+ {
+ if (strcmp(item->value, "immediate") == 0)
+ recoveryTarget = RECOVERY_TARGET_IMMEDIATE;
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid recovery_target parameter"),
+ errhint("The only allowed value is 'immediate'")));
+ ereport(DEBUG2,
+ (errmsg_internal("recovery_target = '%s'",
+ item->value)));
+ }
else if (strcmp(item->name, "recovery_target_inclusive") == 0)
{
/*
bool isCommit;
TimestampTz recordXtime = 0;
- /* We only consider stopping before COMMIT or ABORT records. */
+ /* Check if we should stop as soon as reaching consistency */
+ if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
+ {
+ ereport(LOG,
+ (errmsg("recovery stopping after reaching consistency")));
+
+ recoveryStopAfter = false;
+ recoveryStopXid = InvalidTransactionId;
+ recoveryStopTime = 0;
+ recoveryStopName[0] = '\0';
+ return true;
+ }
+
+ /* Otherwise we only consider stopping before COMMIT or ABORT records. */
if (record->xl_rmid != RM_XACT_ID)
return false;
record_info = record->xl_info & ~XLR_INFO_MASK;
}
}
+ /* Check if we should stop as soon as reaching consistency */
+ if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
+ {
+ ereport(LOG,
+ (errmsg("recovery stopping after reaching consistency")));
+
+ recoveryStopAfter = true;
+ recoveryStopXid = InvalidTransactionId;
+ recoveryStopTime = 0;
+ recoveryStopName[0] = '\0';
+ return true;
+ }
+
return false;
}
ereport(LOG,
(errmsg("starting point-in-time recovery to \"%s\"",
recoveryTargetName)));
+ else if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE)
+ ereport(LOG,
+ (errmsg("starting point-in-time recovery to earliest consistent point")));
else
ereport(LOG,
(errmsg("starting archive recovery")));
snprintf(reason, sizeof(reason),
"at restore point \"%s\"",
recoveryStopName);
+ else if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE)
+ snprintf(reason, sizeof(reason), "reached consistency");
else
snprintf(reason, sizeof(reason), "no recovery target specified");
RECOVERY_TARGET_UNSET,
RECOVERY_TARGET_XID,
RECOVERY_TARGET_TIME,
- RECOVERY_TARGET_NAME
+ RECOVERY_TARGET_NAME,
+ RECOVERY_TARGET_IMMEDIATE
} RecoveryTargetType;
extern XLogRecPtr XactLastRecEnd;