Skip to content

Commit b8e33a8

Browse files
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.
1 parent 198cbe0 commit b8e33a8

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

src/backend/access/transam/recovery.conf.sample

+6-4
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@
9494
#recovery_target_timeline = 'latest'
9595
#
9696
#
97-
# If pause_at_recovery_target is enabled, recovery will pause when
98-
# the recovery target is reached. The pause state will continue until
97+
# If recovery_target_action = 'pause', recovery will pause when the
98+
# recovery target is reached. The pause state will continue until
9999
# pg_xlog_replay_resume() is called. This setting has no effect if
100-
# hot standby is not enabled, or if no recovery target is set.
100+
# no recovery target is set. If hot_standby is not enabled then the
101+
# server will shutdown instead, though you may request this in
102+
# any case by specifying 'shutdown'.
101103
#
102-
#pause_at_recovery_target = true
104+
#recovery_target_action = 'pause'
103105
#
104106
#---------------------------------------------------------------------------
105107
# STANDBY SERVER PARAMETERS

src/backend/access/transam/xlog.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static char *recoveryEndCommand = NULL;
229229
static char *archiveCleanupCommand = NULL;
230230
static RecoveryTargetType recoveryTarget = RECOVERY_TARGET_UNSET;
231231
static bool recoveryTargetInclusive = true;
232-
static RecoveryTargetAction actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PAUSE;
232+
static RecoveryTargetAction recoveryTargetAction = RECOVERY_TARGET_ACTION_PAUSE;
233233
static TransactionId recoveryTargetXid;
234234
static TimestampTz recoveryTargetTime;
235235
static char *recoveryTargetName;
@@ -4654,7 +4654,7 @@ readRecoveryCommandFile(void)
46544654
*head = NULL,
46554655
*tail = NULL;
46564656
bool recoveryPauseAtTargetSet = false;
4657-
bool actionAtRecoveryTargetSet = false;
4657+
bool recoveryTargetActionSet = false;
46584658

46594659

46604660
fd = AllocateFile(RECOVERY_COMMAND_FILE, "r");
@@ -4712,32 +4712,32 @@ readRecoveryCommandFile(void)
47124712
(errmsg_internal("pause_at_recovery_target = '%s'",
47134713
item->value)));
47144714

4715-
actionAtRecoveryTarget = recoveryPauseAtTarget ?
4715+
recoveryTargetAction = recoveryPauseAtTarget ?
47164716
RECOVERY_TARGET_ACTION_PAUSE :
47174717
RECOVERY_TARGET_ACTION_PROMOTE;
47184718

47194719
recoveryPauseAtTargetSet = true;
47204720
}
4721-
else if (strcmp(item->name, "action_at_recovery_target") == 0)
4721+
else if (strcmp(item->name, "recovery_target_action") == 0)
47224722
{
47234723
if (strcmp(item->value, "pause") == 0)
4724-
actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PAUSE;
4724+
recoveryTargetAction = RECOVERY_TARGET_ACTION_PAUSE;
47254725
else if (strcmp(item->value, "promote") == 0)
4726-
actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PROMOTE;
4726+
recoveryTargetAction = RECOVERY_TARGET_ACTION_PROMOTE;
47274727
else if (strcmp(item->value, "shutdown") == 0)
4728-
actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_SHUTDOWN;
4728+
recoveryTargetAction = RECOVERY_TARGET_ACTION_SHUTDOWN;
47294729
else
47304730
ereport(ERROR,
47314731
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
47324732
errmsg("invalid value for recovery parameter \"%s\"",
4733-
"action_at_recovery_target"),
4733+
"recovery_target_action"),
47344734
errhint("The allowed values are \"pause\", \"promote\" and \"shutdown\".")));
47354735

47364736
ereport(DEBUG2,
4737-
(errmsg_internal("action_at_recovery_target = '%s'",
4737+
(errmsg_internal("recovery_target_action = '%s'",
47384738
item->value)));
47394739

4740-
actionAtRecoveryTargetSet = true;
4740+
recoveryTargetActionSet = true;
47414741
}
47424742
else if (strcmp(item->name, "recovery_target_timeline") == 0)
47434743
{
@@ -4905,12 +4905,12 @@ readRecoveryCommandFile(void)
49054905
/*
49064906
* Check for mutually exclusive parameters
49074907
*/
4908-
if (recoveryPauseAtTargetSet && actionAtRecoveryTargetSet)
4908+
if (recoveryPauseAtTargetSet && recoveryTargetActionSet)
49094909
ereport(ERROR,
49104910
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
49114911
errmsg("cannot set both \"%s\" and \"%s\" recovery parameters",
49124912
"pause_at_recovery_target",
4913-
"action_at_recovery_target"),
4913+
"recovery_target_action"),
49144914
errhint("The \"pause_at_recovery_target\" is deprecated.")));
49154915

49164916

@@ -4919,10 +4919,10 @@ readRecoveryCommandFile(void)
49194919
* of behaviour in 9.5; prior to this we simply ignored a request
49204920
* to pause if hot_standby = off, which was surprising behaviour.
49214921
*/
4922-
if (actionAtRecoveryTarget == RECOVERY_TARGET_ACTION_PAUSE &&
4923-
actionAtRecoveryTargetSet &&
4922+
if (recoveryTargetAction == RECOVERY_TARGET_ACTION_PAUSE &&
4923+
recoveryTargetActionSet &&
49244924
standbyState == STANDBY_DISABLED)
4925-
actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_SHUTDOWN;
4925+
recoveryTargetAction = RECOVERY_TARGET_ACTION_SHUTDOWN;
49264926

49274927
/* Enable fetching from archive recovery area */
49284928
ArchiveRecoveryRequested = true;
@@ -6495,7 +6495,7 @@ StartupXLOG(void)
64956495
* this, Resource Managers may choose to do permanent corrective
64966496
* actions at end of recovery.
64976497
*/
6498-
switch (actionAtRecoveryTarget)
6498+
switch (recoveryTargetAction)
64996499
{
65006500
case RECOVERY_TARGET_ACTION_SHUTDOWN:
65016501
/*

0 commit comments

Comments
 (0)