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

Commit6860198

Browse files
committed
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.Reported-by: Yugo NagataAuthor: Yugo Nagata, Kyotaro HoriguchiReviewed-by: Ranier Vilela, Fujii MasaoDiscussion:https://postgr.es/m/20210718045505.32f463ed6c227111038d8ae4@sraoss.co.jp
1 parentf3fec23 commit6860198

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
@@ -12423,7 +12423,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
1242312423

1242412424
/*
1242512425
* Check the page header immediately, so that we can retry immediately if
12426-
* it's not valid. This may seem unnecessary, becauseXLogReadRecord()
12426+
* it's not valid. This may seem unnecessary, becauseReadPageInternal()
1242712427
* validates the page header anyway, and would propagate the failure up to
1242812428
* ReadRecord(), which would retry. However, there's a corner case with
1242912429
* continuation records, if a record is split across two pages such that
@@ -12447,9 +12447,23 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
1244712447
*
1244812448
* Validating the page header is cheap enough that doing it twice
1244912449
* shouldn't be a big deal from a performance point of view.
12450+
*
12451+
* When not in standby mode, an invalid page header should cause recovery
12452+
* to end, not retry reading the page, so we don't need to validate the
12453+
* page header here for the retry. Instead, ReadPageInternal() is
12454+
* responsible for the validation.
1245012455
*/
12451-
if (!XLogReaderValidatePageHeader(xlogreader,targetPagePtr,readBuf))
12456+
if (StandbyMode&&
12457+
!XLogReaderValidatePageHeader(xlogreader,targetPagePtr,readBuf))
1245212458
{
12459+
/*
12460+
* Emit this error right now then retry this page immediately. Use
12461+
* errmsg_internal() because the message was already translated.
12462+
*/
12463+
if (xlogreader->errormsg_buf[0])
12464+
ereport(emode_for_corrupt_record(emode,EndRecPtr),
12465+
(errmsg_internal("%s",xlogreader->errormsg_buf)));
12466+
1245312467
/* reset any error XLogReaderValidatePageHeader() might have set */
1245412468
xlogreader->errormsg_buf[0]='\0';
1245512469
gotonext_record_is_invalid;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp