On 05/12/14 16:49, Robert Haas wrote:
On Thu, Dec 4, 2014 at 8:45 AM, Michael Paquier
<michael.paqu...@gmail.com> wrote:
Here is patch which renames action_at_recovery_target to
recovery_target_action everywhere.
Thanks, Looks good to me.
A couple of things that would be good to document as well in
recovery-config.sgml:
- the fact that pause_at_recovery_target is deprecated.
Why not just remove it altogether? I don't think the
backward-compatibility break is enough to get excited about, or to
justify the annoyance of carrying an extra parameter that does (part
of) the same thing.
Ok this patch does that, along with the rename to recovery_target_action
and addition to the recovery.conf.sample.
--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
diff --git a/doc/src/sgml/recovery-config.sgml b/doc/src/sgml/recovery-config.sgml
index b4959ac..519a0ce 100644
--- a/doc/src/sgml/recovery-config.sgml
+++ b/doc/src/sgml/recovery-config.sgml
@@ -280,31 +280,11 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
</listitem>
</varlistentry>
- <varlistentry id="pause-at-recovery-target"
- xreflabel="pause_at_recovery_target">
- <term><varname>pause_at_recovery_target</varname> (<type>boolean</type>)
+ <varlistentry id="recovery-target-action"
+ xreflabel="recovery_target_action">
+ <term><varname>recovery_target_action</varname> (<type>enum</type>)
<indexterm>
- <primary><varname>pause_at_recovery_target</> recovery parameter</primary>
- </indexterm>
- </term>
- <listitem>
- <para>
- Alias for action_at_recovery_target, <literal>true</> is same as
- action_at_recovery_target = <literal>pause</> and <literal>false</>
- is same as action_at_recovery_target = <literal>promote</>.
- </para>
- <para>
- This setting has no effect if <xref linkend="guc-hot-standby"> is not
- enabled, or if no recovery target is set.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry id="action-at-recovery-target"
- xreflabel="action_at_recovery_target">
- <term><varname>action_at_recovery_target</varname> (<type>enum</type>)
- <indexterm>
- <primary><varname>action_at_recovery_target</> recovery parameter</primary>
+ <primary><varname>recovery_target_action</> recovery parameter</primary>
</indexterm>
</term>
<listitem>
@@ -336,7 +316,7 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
</para>
<para>
Note that because <filename>recovery.conf</> will not be renamed when
- <varname>action_at_recovery_target</> is set to <literal>shutdown</>,
+ <varname>recovery_target_action</> is set to <literal>shutdown</>,
any subsequent start will end with immediate shutdown unless the
configuration is changed or the <filename>recovery.conf</> is removed
manually.
diff --git a/doc/src/sgml/release-9.1.sgml b/doc/src/sgml/release-9.1.sgml
index 79a8b07..4fcc0b3 100644
--- a/doc/src/sgml/release-9.1.sgml
+++ b/doc/src/sgml/release-9.1.sgml
@@ -6301,8 +6301,7 @@
<listitem>
<para>
- Add <filename>recovery.conf</> setting <link
- linkend="pause-at-recovery-target"><varname>pause_at_recovery_target</></link>
+ Add <filename>recovery.conf</> setting <varname>pause_at_recovery_target</>
to pause recovery at target (Simon Riggs)
</para>
diff --git a/src/backend/access/transam/recovery.conf.sample b/src/backend/access/transam/recovery.conf.sample
index 7657df3..42da62b 100644
--- a/src/backend/access/transam/recovery.conf.sample
+++ b/src/backend/access/transam/recovery.conf.sample
@@ -94,12 +94,13 @@
#recovery_target_timeline = 'latest'
#
#
-# If pause_at_recovery_target is enabled, recovery will pause when
-# the recovery target is reached. The pause state will continue until
-# pg_xlog_replay_resume() is called. This setting has no effect if
-# hot standby is not enabled, or if no recovery target is set.
+# The recovery_target_action option can be set to either promote, paused
+# or shutdown and decides the behaviour of the server once the recovery_target
+# is reached. Promote will promote the server to standalone one. Pause will
+# pause the recovery, which can be then resumed by pg_xlog_replay_resume().
+# And shutdown will stop the server.
#
-#pause_at_recovery_target = true
+#recovery_target_action = 'pause'
#
#---------------------------------------------------------------------------
# STANDBY SERVER PARAMETERS
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index da28de9..469a83b 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -229,7 +229,7 @@ static char *recoveryEndCommand = NULL;
static char *archiveCleanupCommand = NULL;
static RecoveryTargetType recoveryTarget = RECOVERY_TARGET_UNSET;
static bool recoveryTargetInclusive = true;
-static RecoveryTargetAction actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PAUSE;
+static RecoveryTargetAction recoveryTargetAction = RECOVERY_TARGET_ACTION_PAUSE;
static TransactionId recoveryTargetXid;
static TimestampTz recoveryTargetTime;
static char *recoveryTargetName;
@@ -4653,8 +4653,7 @@ readRecoveryCommandFile(void)
ConfigVariable *item,
*head = NULL,
*tail = NULL;
- bool recoveryPauseAtTargetSet = false;
- bool actionAtRecoveryTargetSet = false;
+ bool recoveryTargetActionSet = false;
fd = AllocateFile(RECOVERY_COMMAND_FILE, "r");
@@ -4699,45 +4698,26 @@ readRecoveryCommandFile(void)
(errmsg_internal("archive_cleanup_command = '%s'",
archiveCleanupCommand)));
}
- else if (strcmp(item->name, "pause_at_recovery_target") == 0)
- {
- bool recoveryPauseAtTarget;
-
- if (!parse_bool(item->value, &recoveryPauseAtTarget))
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("parameter \"%s\" requires a Boolean value", "pause_at_recovery_target")));
-
- ereport(DEBUG2,
- (errmsg_internal("pause_at_recovery_target = '%s'",
- item->value)));
-
- actionAtRecoveryTarget = recoveryPauseAtTarget ?
- RECOVERY_TARGET_ACTION_PAUSE :
- RECOVERY_TARGET_ACTION_PROMOTE;
-
- 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)
- actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PAUSE;
+ recoveryTargetAction = RECOVERY_TARGET_ACTION_PAUSE;
else if (strcmp(item->value, "promote") == 0)
- actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_PROMOTE;
+ recoveryTargetAction = RECOVERY_TARGET_ACTION_PROMOTE;
else if (strcmp(item->value, "shutdown") == 0)
- actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_SHUTDOWN;
+ recoveryTargetAction = RECOVERY_TARGET_ACTION_SHUTDOWN;
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid value for recovery parameter \"%s\"",
- "action_at_recovery_target"),
+ "recovery_target_action"),
errhint("The allowed values are \"pause\", \"promote\" and \"shutdown\".")));
ereport(DEBUG2,
- (errmsg_internal("action_at_recovery_target = '%s'",
+ (errmsg_internal("recovery_target_action = '%s'",
item->value)));
- actionAtRecoveryTargetSet = true;
+ recoveryTargetActionSet = true;
}
else if (strcmp(item->name, "recovery_target_timeline") == 0)
{
@@ -4902,27 +4882,16 @@ readRecoveryCommandFile(void)
RECOVERY_COMMAND_FILE)));
}
- /*
- * Check for mutually exclusive parameters
- */
- if (recoveryPauseAtTargetSet && actionAtRecoveryTargetSet)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("cannot set both \"%s\" and \"%s\" recovery parameters",
- "pause_at_recovery_target",
- "action_at_recovery_target"),
- errhint("The \"pause_at_recovery_target\" is deprecated.")));
-
/*
- * Override any inconsistent requests. Not that this is a change
+ * Override any inconsistent requests. Note that this is a change
* of behaviour in 9.5; prior to this we simply ignored a request
* to pause if hot_standby = off, which was surprising behaviour.
*/
- if (actionAtRecoveryTarget == RECOVERY_TARGET_ACTION_PAUSE &&
- actionAtRecoveryTargetSet &&
+ if (recoveryTargetAction == RECOVERY_TARGET_ACTION_PAUSE &&
+ recoveryTargetActionSet &&
standbyState == STANDBY_DISABLED)
- actionAtRecoveryTarget = RECOVERY_TARGET_ACTION_SHUTDOWN;
+ recoveryTargetAction = RECOVERY_TARGET_ACTION_SHUTDOWN;
/* Enable fetching from archive recovery area */
ArchiveRecoveryRequested = true;
@@ -6495,7 +6464,7 @@ StartupXLOG(void)
* this, Resource Managers may choose to do permanent corrective
* actions at end of recovery.
*/
- switch (actionAtRecoveryTarget)
+ switch (recoveryTargetAction)
{
case RECOVERY_TARGET_ACTION_SHUTDOWN:
/*
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers