aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-08-31 08:52:13 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-08-31 08:52:13 -0400
commitc40bb11559c516c24ff1460e2fac5da20abfeb39 (patch)
tree083940ce28c5211a7a5247908f6ad2cf69d0713e /src/backend
parent3aa233f82fad7ba46c93045408d2052ab1450e15 (diff)
downloadpostgresql-c40bb11559c516c24ff1460e2fac5da20abfeb39.tar.gz
postgresql-c40bb11559c516c24ff1460e2fac5da20abfeb39.zip
Prevent starting a standalone backend with standby_mode on.
This can't really work because standby_mode expects there to be more WAL arriving, which there will not ever be because there's no WAL receiver process to fetch it. Moreover, if standby_mode is on then hot standby might also be turned on, causing even more strangeness because that expects read-only sessions to be executing in parallel. Bernd Helmle reported a case where btree_xlog_delete_get_latestRemovedXid got confused, but rather than band-aiding individual problems it seems best to prevent getting anywhere near this state in the first place. Back-patch to all supported branches. In passing, also fix some omissions of errcodes in other ereport's in readRecoveryCommandFile(). Michael Paquier (errcode hacking by me) Discussion: <00F0B2CEF6D0CEF8A90119D4@eje.credativ.lan>
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/transam/xlog.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 9899cbb6c75..63154a16754 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -4980,7 +4980,8 @@ readRecoveryCommandFile(void)
rtli = (TimeLineID) strtoul(item->value, NULL, 0);
if (errno == EINVAL || errno == ERANGE)
ereport(FATAL,
- (errmsg("recovery_target_timeline is not a valid number: \"%s\"",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("recovery_target_timeline is not a valid number: \"%s\"",
item->value)));
}
if (rtli)
@@ -4996,7 +4997,8 @@ readRecoveryCommandFile(void)
recoveryTargetXid = (TransactionId) strtoul(item->value, NULL, 0);
if (errno == EINVAL || errno == ERANGE)
ereport(FATAL,
- (errmsg("recovery_target_xid is not a valid number: \"%s\"",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("recovery_target_xid is not a valid number: \"%s\"",
item->value)));
ereport(DEBUG2,
(errmsg_internal("recovery_target_xid = %u",
@@ -5111,7 +5113,8 @@ readRecoveryCommandFile(void)
}
else
ereport(FATAL,
- (errmsg("unrecognized recovery parameter \"%s\"",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("unrecognized recovery parameter \"%s\"",
item->name)));
}
@@ -5130,7 +5133,8 @@ readRecoveryCommandFile(void)
{
if (recoveryRestoreCommand == NULL)
ereport(FATAL,
- (errmsg("recovery command file \"%s\" must specify restore_command when standby mode is not enabled",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("recovery command file \"%s\" must specify restore_command when standby mode is not enabled",
RECOVERY_COMMAND_FILE)));
}
@@ -5144,6 +5148,15 @@ readRecoveryCommandFile(void)
!EnableHotStandby)
recoveryTargetAction = RECOVERY_TARGET_ACTION_SHUTDOWN;
+ /*
+ * We don't support standby_mode in standalone backends; that requires
+ * other processes such as the WAL receiver to be alive.
+ */
+ if (StandbyModeRequested && !IsUnderPostmaster)
+ ereport(FATAL,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("standby mode is not supported by single-user servers")));
+
/* Enable fetching from archive recovery area */
ArchiveRecoveryRequested = true;
@@ -5160,7 +5173,8 @@ readRecoveryCommandFile(void)
/* Timeline 1 does not have a history file, all else should */
if (rtli != 1 && !existsTimeLineHistory(rtli))
ereport(FATAL,
- (errmsg("recovery target timeline %u does not exist",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("recovery target timeline %u does not exist",
rtli)));
recoveryTargetTLI = rtli;
recoveryTargetIsLatest = false;