Commit b8e33a85 authored by Simon Riggs's avatar Simon Riggs

Tweaks for recovery_target_action

Rename parameter action_at_recovery_target to
recovery_target_action suggested by Christoph Berg.

Place into recovery.conf suggested by Fujii Masao,
replacing (deprecating) earlier parameters, per
Michael Paquier.
parent 198cbe0a
...@@ -94,12 +94,14 @@ ...@@ -94,12 +94,14 @@
#recovery_target_timeline = 'latest' #recovery_target_timeline = 'latest'
# #
# #
# If pause_at_recovery_target is enabled, recovery will pause when # If recovery_target_action = 'pause', recovery will pause when the
# the recovery target is reached. The pause state will continue until # recovery target is reached. The pause state will continue until
# pg_xlog_replay_resume() is called. This setting has no effect if # pg_xlog_replay_resume() is called. This setting has no effect if
# hot standby is not enabled, or if no recovery target is set. # no recovery target is set. If hot_standby is not enabled then the
# server will shutdown instead, though you may request this in
# any case by specifying 'shutdown'.
# #
#pause_at_recovery_target = true #recovery_target_action = 'pause'
# #
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# STANDBY SERVER PARAMETERS # STANDBY SERVER PARAMETERS
......
...@@ -229,7 +229,7 @@ static char *recoveryEndCommand = NULL; ...@@ -229,7 +229,7 @@ static char *recoveryEndCommand = NULL;
static char *archiveCleanupCommand = NULL; static char *archiveCleanupCommand = NULL;
static RecoveryTargetType recoveryTarget = RECOVERY_TARGET_UNSET; static RecoveryTargetType recoveryTarget = RECOVERY_TARGET_UNSET;
static bool recoveryTargetInclusive = true; static bool recoveryTargetInclusive = true;
static RecoveryTargetAction actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PAUSE; static RecoveryTargetAction recoveryTargetAction = RECOVERY_TARGET_ACTION_PAUSE;
static TransactionId recoveryTargetXid; static TransactionId recoveryTargetXid;
static TimestampTz recoveryTargetTime; static TimestampTz recoveryTargetTime;
static char *recoveryTargetName; static char *recoveryTargetName;
...@@ -4654,7 +4654,7 @@ readRecoveryCommandFile(void) ...@@ -4654,7 +4654,7 @@ readRecoveryCommandFile(void)
*head = NULL, *head = NULL,
*tail = NULL; *tail = NULL;
bool recoveryPauseAtTargetSet = false; bool recoveryPauseAtTargetSet = false;
bool actionAtRecoveryTargetSet = false; bool recoveryTargetActionSet = false;
fd = AllocateFile(RECOVERY_COMMAND_FILE, "r"); fd = AllocateFile(RECOVERY_COMMAND_FILE, "r");
...@@ -4712,32 +4712,32 @@ readRecoveryCommandFile(void) ...@@ -4712,32 +4712,32 @@ readRecoveryCommandFile(void)
(errmsg_internal("pause_at_recovery_target = '%s'", (errmsg_internal("pause_at_recovery_target = '%s'",
item->value))); item->value)));
actionAtRecoveryTarget = recoveryPauseAtTarget ? recoveryTargetAction = recoveryPauseAtTarget ?
RECOVERY_TARGET_ACTION_PAUSE : RECOVERY_TARGET_ACTION_PAUSE :
RECOVERY_TARGET_ACTION_PROMOTE; RECOVERY_TARGET_ACTION_PROMOTE;
recoveryPauseAtTargetSet = true; recoveryPauseAtTargetSet = true;
} }
else if (strcmp(item->name, "action_at_recovery_target") == 0) else if (strcmp(item->name, "recovery_target_action") == 0)
{ {
if (strcmp(item->value, "pause") == 0) if (strcmp(item->value, "pause") == 0)
actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PAUSE; recoveryTargetAction = RECOVERY_TARGET_ACTION_PAUSE;
else if (strcmp(item->value, "promote") == 0) else if (strcmp(item->value, "promote") == 0)
actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PROMOTE; recoveryTargetAction = RECOVERY_TARGET_ACTION_PROMOTE;
else if (strcmp(item->value, "shutdown") == 0) else if (strcmp(item->value, "shutdown") == 0)
actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_SHUTDOWN; recoveryTargetAction = RECOVERY_TARGET_ACTION_SHUTDOWN;
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid value for recovery parameter \"%s\"", errmsg("invalid value for recovery parameter \"%s\"",
"action_at_recovery_target"), "recovery_target_action"),
errhint("The allowed values are \"pause\", \"promote\" and \"shutdown\"."))); errhint("The allowed values are \"pause\", \"promote\" and \"shutdown\".")));
ereport(DEBUG2, ereport(DEBUG2,
(errmsg_internal("action_at_recovery_target = '%s'", (errmsg_internal("recovery_target_action = '%s'",
item->value))); item->value)));
actionAtRecoveryTargetSet = true; recoveryTargetActionSet = true;
} }
else if (strcmp(item->name, "recovery_target_timeline") == 0) else if (strcmp(item->name, "recovery_target_timeline") == 0)
{ {
...@@ -4905,12 +4905,12 @@ readRecoveryCommandFile(void) ...@@ -4905,12 +4905,12 @@ readRecoveryCommandFile(void)
/* /*
* Check for mutually exclusive parameters * Check for mutually exclusive parameters
*/ */
if (recoveryPauseAtTargetSet && actionAtRecoveryTargetSet) if (recoveryPauseAtTargetSet && recoveryTargetActionSet)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot set both \"%s\" and \"%s\" recovery parameters", errmsg("cannot set both \"%s\" and \"%s\" recovery parameters",
"pause_at_recovery_target", "pause_at_recovery_target",
"action_at_recovery_target"), "recovery_target_action"),
errhint("The \"pause_at_recovery_target\" is deprecated."))); errhint("The \"pause_at_recovery_target\" is deprecated.")));
...@@ -4919,10 +4919,10 @@ readRecoveryCommandFile(void) ...@@ -4919,10 +4919,10 @@ readRecoveryCommandFile(void)
* of behaviour in 9.5; prior to this we simply ignored a request * of behaviour in 9.5; prior to this we simply ignored a request
* to pause if hot_standby = off, which was surprising behaviour. * to pause if hot_standby = off, which was surprising behaviour.
*/ */
if (actionAtRecoveryTarget == RECOVERY_TARGET_ACTION_PAUSE && if (recoveryTargetAction == RECOVERY_TARGET_ACTION_PAUSE &&
actionAtRecoveryTargetSet && recoveryTargetActionSet &&
standbyState == STANDBY_DISABLED) standbyState == STANDBY_DISABLED)
actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_SHUTDOWN; recoveryTargetAction = RECOVERY_TARGET_ACTION_SHUTDOWN;
/* Enable fetching from archive recovery area */ /* Enable fetching from archive recovery area */
ArchiveRecoveryRequested = true; ArchiveRecoveryRequested = true;
...@@ -6495,7 +6495,7 @@ StartupXLOG(void) ...@@ -6495,7 +6495,7 @@ StartupXLOG(void)
* this, Resource Managers may choose to do permanent corrective * this, Resource Managers may choose to do permanent corrective
* actions at end of recovery. * actions at end of recovery.
*/ */
switch (actionAtRecoveryTarget) switch (recoveryTargetAction)
{ {
case RECOVERY_TARGET_ACTION_SHUTDOWN: case RECOVERY_TARGET_ACTION_SHUTDOWN:
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment