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

Commit0c6293d

Browse files
committed
Before removing backup_label and irrevocably changing pg_control file, check
that WAL file containing the checkpoint redo-location can be found. Thisavoids making the cluster irrecoverable if the redo location is in an earlieWAL file than the checkpoint record.Report, analysis and patch by Jeff Davis, with small changes by me.
1 parenta87d212 commit0c6293d

File tree

1 file changed

+17
-2
lines changed
  • src/backend/access/transam

1 file changed

+17
-2
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5839,14 +5839,29 @@ StartupXLOG(void)
58395839
record=ReadCheckpointRecord(checkPointLoc,0);
58405840
if (record!=NULL)
58415841
{
5842+
memcpy(&checkPoint,XLogRecGetData(record),sizeof(CheckPoint));
58425843
ereport(DEBUG1,
58435844
(errmsg("checkpoint record is at %X/%X",
58445845
checkPointLoc.xlogid,checkPointLoc.xrecoff)));
58455846
InRecovery= true;/* force recovery even if SHUTDOWNED */
5847+
5848+
/*
5849+
* Make sure that REDO location exists. This may not be
5850+
* the case if there was a crash during an online backup,
5851+
* which left a backup_label around that references a WAL
5852+
* segment that's already been archived.
5853+
*/
5854+
if (XLByteLT(checkPoint.redo,checkPointLoc))
5855+
{
5856+
if (!ReadRecord(&(checkPoint.redo),LOG, false))
5857+
ereport(FATAL,
5858+
(errmsg("could not find redo location referenced by checkpoint record"),
5859+
errhint("If you are not restoring from a backup, try removing the file \"%s/backup_label\".",DataDir)));
5860+
}
58465861
}
58475862
else
58485863
{
5849-
ereport(PANIC,
5864+
ereport(FATAL,
58505865
(errmsg("could not locate required checkpoint record"),
58515866
errhint("If you are not restoring from a backup, try removing the file \"%s/backup_label\".",DataDir)));
58525867
}
@@ -5892,10 +5907,10 @@ StartupXLOG(void)
58925907
ereport(PANIC,
58935908
(errmsg("could not locate a valid checkpoint record")));
58945909
}
5910+
memcpy(&checkPoint,XLogRecGetData(record),sizeof(CheckPoint));
58955911
}
58965912

58975913
LastRec=RecPtr=checkPointLoc;
5898-
memcpy(&checkPoint,XLogRecGetData(record),sizeof(CheckPoint));
58995914
wasShutdown= (record->xl_info==XLOG_CHECKPOINT_SHUTDOWN);
59005915

59015916
ereport(DEBUG1,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp