aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2019-11-08 08:03:16 +0100
committerPeter Eisentraut <peter@eisentraut.org>2019-11-08 08:03:16 +0100
commitb85e43feb3e837699239aba6b8e0f280a59417be (patch)
treed349f6fb09cf907e8125f5e3b528f7607e85d2d3 /src/backend/access/transam/xlog.c
parente86c8ef243aad4570f66a406c81211f75774ced1 (diff)
downloadpostgresql-b85e43feb3e837699239aba6b8e0f280a59417be.tar.gz
postgresql-b85e43feb3e837699239aba6b8e0f280a59417be.zip
More precise errors from initial pg_control check
Use a separate error message for invalid checkpoint location and invalid state instead of just "invalid data" for both. Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/20191107041630.GK1768@paquier.xyz
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c82
1 files changed, 48 insertions, 34 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 2e3cc510060..55d01a86c73 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6231,45 +6231,59 @@ StartupXLOG(void)
CurrentResourceOwner = AuxProcessResourceOwner;
/*
- * Verify XLOG status looks valid.
+ * Check that contents look valid.
*/
- if (ControlFile->state < DB_SHUTDOWNED ||
- ControlFile->state > DB_IN_PRODUCTION ||
- !XRecOffIsValid(ControlFile->checkPoint))
+ if (!XRecOffIsValid(ControlFile->checkPoint))
ereport(FATAL,
- (errmsg("control file contains invalid data")));
+ (errmsg("control file contains invalid checkpoint location")));
- if (ControlFile->state == DB_SHUTDOWNED)
+ switch (ControlFile->state)
{
- /* This is the expected case, so don't be chatty in standalone mode */
- ereport(IsPostmasterEnvironment ? LOG : NOTICE,
- (errmsg("database system was shut down at %s",
- str_time(ControlFile->time))));
+ case DB_SHUTDOWNED:
+ /* This is the expected case, so don't be chatty in standalone mode */
+ ereport(IsPostmasterEnvironment ? LOG : NOTICE,
+ (errmsg("database system was shut down at %s",
+ str_time(ControlFile->time))));
+ break;
+
+ case DB_SHUTDOWNED_IN_RECOVERY:
+ ereport(LOG,
+ (errmsg("database system was shut down in recovery at %s",
+ str_time(ControlFile->time))));
+ break;
+
+ case DB_SHUTDOWNING:
+ ereport(LOG,
+ (errmsg("database system shutdown was interrupted; last known up at %s",
+ str_time(ControlFile->time))));
+ break;
+
+ case DB_IN_CRASH_RECOVERY:
+ ereport(LOG,
+ (errmsg("database system was interrupted while in recovery at %s",
+ str_time(ControlFile->time)),
+ errhint("This probably means that some data is corrupted and"
+ " you will have to use the last backup for recovery.")));
+ break;
+
+ case DB_IN_ARCHIVE_RECOVERY:
+ ereport(LOG,
+ (errmsg("database system was interrupted while in recovery at log time %s",
+ str_time(ControlFile->checkPointCopy.time)),
+ errhint("If this has occurred more than once some data might be corrupted"
+ " and you might need to choose an earlier recovery target.")));
+ break;
+
+ case DB_IN_PRODUCTION:
+ ereport(LOG,
+ (errmsg("database system was interrupted; last known up at %s",
+ str_time(ControlFile->time))));
+ break;
+
+ default:
+ ereport(FATAL,
+ (errmsg("control file contains invalid database cluster state")));
}
- else if (ControlFile->state == DB_SHUTDOWNED_IN_RECOVERY)
- ereport(LOG,
- (errmsg("database system was shut down in recovery at %s",
- str_time(ControlFile->time))));
- else if (ControlFile->state == DB_SHUTDOWNING)
- ereport(LOG,
- (errmsg("database system shutdown was interrupted; last known up at %s",
- str_time(ControlFile->time))));
- else if (ControlFile->state == DB_IN_CRASH_RECOVERY)
- ereport(LOG,
- (errmsg("database system was interrupted while in recovery at %s",
- str_time(ControlFile->time)),
- errhint("This probably means that some data is corrupted and"
- " you will have to use the last backup for recovery.")));
- else if (ControlFile->state == DB_IN_ARCHIVE_RECOVERY)
- ereport(LOG,
- (errmsg("database system was interrupted while in recovery at log time %s",
- str_time(ControlFile->checkPointCopy.time)),
- errhint("If this has occurred more than once some data might be corrupted"
- " and you might need to choose an earlier recovery target.")));
- else if (ControlFile->state == DB_IN_PRODUCTION)
- ereport(LOG,
- (errmsg("database system was interrupted; last known up at %s",
- str_time(ControlFile->time))));
/* This is just to allow attaching to startup process with a debugger */
#ifdef XLOG_REPLAY_DELAY