Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb85e43f

Browse files
committed
More precise errors from initial pg_control check
Use a separate error message for invalid checkpoint location andinvalid 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
1 parente86c8ef commitb85e43f

File tree

1 file changed

+48
-34
lines changed
  • src/backend/access/transam

1 file changed

+48
-34
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6231,45 +6231,59 @@ StartupXLOG(void)
62316231
CurrentResourceOwner=AuxProcessResourceOwner;
62326232

62336233
/*
6234-
*Verify XLOG status looks valid.
6234+
*Check that contents look valid.
62356235
*/
6236-
if (ControlFile->state<DB_SHUTDOWNED||
6237-
ControlFile->state>DB_IN_PRODUCTION||
6238-
!XRecOffIsValid(ControlFile->checkPoint))
6236+
if (!XRecOffIsValid(ControlFile->checkPoint))
62396237
ereport(FATAL,
6240-
(errmsg("control file contains invaliddata")));
6238+
(errmsg("control file contains invalidcheckpoint location")));
62416239

6242-
if (ControlFile->state==DB_SHUTDOWNED)
6240+
switch (ControlFile->state)
62436241
{
6244-
/* This is the expected case, so don't be chatty in standalone mode */
6245-
ereport(IsPostmasterEnvironment ?LOG :NOTICE,
6246-
(errmsg("database system was shut down at %s",
6247-
str_time(ControlFile->time))));
6242+
caseDB_SHUTDOWNED:
6243+
/* This is the expected case, so don't be chatty in standalone mode */
6244+
ereport(IsPostmasterEnvironment ?LOG :NOTICE,
6245+
(errmsg("database system was shut down at %s",
6246+
str_time(ControlFile->time))));
6247+
break;
6248+
6249+
caseDB_SHUTDOWNED_IN_RECOVERY:
6250+
ereport(LOG,
6251+
(errmsg("database system was shut down in recovery at %s",
6252+
str_time(ControlFile->time))));
6253+
break;
6254+
6255+
caseDB_SHUTDOWNING:
6256+
ereport(LOG,
6257+
(errmsg("database system shutdown was interrupted; last known up at %s",
6258+
str_time(ControlFile->time))));
6259+
break;
6260+
6261+
caseDB_IN_CRASH_RECOVERY:
6262+
ereport(LOG,
6263+
(errmsg("database system was interrupted while in recovery at %s",
6264+
str_time(ControlFile->time)),
6265+
errhint("This probably means that some data is corrupted and"
6266+
" you will have to use the last backup for recovery.")));
6267+
break;
6268+
6269+
caseDB_IN_ARCHIVE_RECOVERY:
6270+
ereport(LOG,
6271+
(errmsg("database system was interrupted while in recovery at log time %s",
6272+
str_time(ControlFile->checkPointCopy.time)),
6273+
errhint("If this has occurred more than once some data might be corrupted"
6274+
" and you might need to choose an earlier recovery target.")));
6275+
break;
6276+
6277+
caseDB_IN_PRODUCTION:
6278+
ereport(LOG,
6279+
(errmsg("database system was interrupted; last known up at %s",
6280+
str_time(ControlFile->time))));
6281+
break;
6282+
6283+
default:
6284+
ereport(FATAL,
6285+
(errmsg("control file contains invalid database cluster state")));
62486286
}
6249-
elseif (ControlFile->state==DB_SHUTDOWNED_IN_RECOVERY)
6250-
ereport(LOG,
6251-
(errmsg("database system was shut down in recovery at %s",
6252-
str_time(ControlFile->time))));
6253-
elseif (ControlFile->state==DB_SHUTDOWNING)
6254-
ereport(LOG,
6255-
(errmsg("database system shutdown was interrupted; last known up at %s",
6256-
str_time(ControlFile->time))));
6257-
elseif (ControlFile->state==DB_IN_CRASH_RECOVERY)
6258-
ereport(LOG,
6259-
(errmsg("database system was interrupted while in recovery at %s",
6260-
str_time(ControlFile->time)),
6261-
errhint("This probably means that some data is corrupted and"
6262-
" you will have to use the last backup for recovery.")));
6263-
elseif (ControlFile->state==DB_IN_ARCHIVE_RECOVERY)
6264-
ereport(LOG,
6265-
(errmsg("database system was interrupted while in recovery at log time %s",
6266-
str_time(ControlFile->checkPointCopy.time)),
6267-
errhint("If this has occurred more than once some data might be corrupted"
6268-
" and you might need to choose an earlier recovery target.")));
6269-
elseif (ControlFile->state==DB_IN_PRODUCTION)
6270-
ereport(LOG,
6271-
(errmsg("database system was interrupted; last known up at %s",
6272-
str_time(ControlFile->time))));
62736287

62746288
/* This is just to allow attaching to startup process with a debugger */
62756289
#ifdefXLOG_REPLAY_DELAY

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp