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

Commit5dc093e

Browse files
MasaoFujiimichaelpq
authored andcommitted
Make recovery report error message when invalid page header is found.
Commit0668719 changed XLogPageRead() so that it validated the pageheader, if invalid page header was found reset the error message andretried reading the page, to fix the scenario where streaming standbygot stuck at a continuation record. This change hid the error messageabout invalid page header, which would make it harder for users toinvestigate what the actual issue was found in WAL.To fix the issue, this commit makes XLogPageRead() report the errormessage when invalid page header is found.When not in standby mode, an invalid page header should cause recoveryto end, not retry reading the page, so XLogPageRead() doesn't need tovalidate the page header for the retry. Instead, ReadPageInternal() shouldbe responsible for the validation in that case. Therefore this commitchanges XLogPageRead() so that if not in standby mode it doesn't validatethe page header for the retry.This commit has been originally pushed as of6860198 for 15 andnewer versions, but not to the older branches. A recent investigationrelated to WAL replay failures has showed up that the lack of this patchin 12~14 is an issue, as we want to be able to improve the WAL reader tomake a correct distinction between the end-of-wal and OOM cases whenvalidating record headers. REL_11_STABLE is left out as it will beEOL'd soon.Reported-by: Yugo NagataAuthor: Yugo Nagata, Kyotaro HoriguchiReviewed-by: Ranier Vilela, Fujii MasaoDiscussion:https://postgr.es/m/20210718045505.32f463ed6c227111038d8ae4@sraoss.co.jpDiscussion:https://postgr.es/m/17928-aa92416a70ff44a2@postgresql.orgBackpatch-through: 12
1 parent5ab7c53 commit5dc093e

File tree

1 file changed

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

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12299,7 +12299,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
1229912299

1230012300
/*
1230112301
* Check the page header immediately, so that we can retry immediately if
12302-
* it's not valid. This may seem unnecessary, becauseXLogReadRecord()
12302+
* it's not valid. This may seem unnecessary, becauseReadPageInternal()
1230312303
* validates the page header anyway, and would propagate the failure up to
1230412304
* ReadRecord(), which would retry. However, there's a corner case with
1230512305
* continuation records, if a record is split across two pages such that
@@ -12322,9 +12322,23 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
1232212322
*
1232312323
* Validating the page header is cheap enough that doing it twice
1232412324
* shouldn't be a big deal from a performance point of view.
12325+
*
12326+
* When not in standby mode, an invalid page header should cause recovery
12327+
* to end, not retry reading the page, so we don't need to validate the
12328+
* page header here for the retry. Instead, ReadPageInternal() is
12329+
* responsible for the validation.
1232512330
*/
12326-
if (!XLogReaderValidatePageHeader(xlogreader,targetPagePtr,readBuf))
12331+
if (StandbyMode&&
12332+
!XLogReaderValidatePageHeader(xlogreader,targetPagePtr,readBuf))
1232712333
{
12334+
/*
12335+
* Emit this error right now then retry this page immediately. Use
12336+
* errmsg_internal() because the message was already translated.
12337+
*/
12338+
if (xlogreader->errormsg_buf[0])
12339+
ereport(emode_for_corrupt_record(emode,EndRecPtr),
12340+
(errmsg_internal("%s",xlogreader->errormsg_buf)));
12341+
1232812342
/* reset any error XLogReaderValidatePageHeader() might have set */
1232912343
xlogreader->errormsg_buf[0]='\0';
1233012344
gotonext_record_is_invalid;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp