Re: corruption of WAL page header is never reported

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: nagata(at)sraoss(dot)co(dot)jp, ranier(dot)vf(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: corruption of WAL page header is never reported
Date: 2021-09-06 17:02:38
Message-ID: c6f938ac-43ad-d3d1-a502-5322f68ed69b@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021/09/06 3:11, Alvaro Herrera wrote:
> On 2021-Sep-03, Kyotaro Horiguchi wrote:
>
>> diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
>> index 24165ab03e..b621ad6b0f 100644
>> --- a/src/backend/access/transam/xlog.c
>> +++ b/src/backend/access/transam/xlog.c
>> @@ -12496,9 +12496,21 @@ retry:
>> *
>> * Validating the page header is cheap enough that doing it twice
>> * shouldn't be a big deal from a performance point of view.
>> + *
>> + * Don't call XLogReaderValidatePageHeader here while not in standby mode
>> + * so that this function won't return with a valid errmsg_buf.
>> */
>> - if (!XLogReaderValidatePageHeader(xlogreader, targetPagePtr, readBuf))
>> + if (StandbyMode &&
>> + !XLogReaderValidatePageHeader(xlogreader, targetPagePtr, readBuf))
>
> OK, but I don't understand why we have a comment that says (referring to
> non-standby mode) "doing it twice shouldn't be a big deal", followed by
> "Don't do it twice while not in standby mode" -- that seems quite
> contradictory. I think the new comment should overwrite the previous
> one, something like this:
>
> - * Validating the page header is cheap enough that doing it twice
> - * shouldn't be a big deal from a performance point of view.
> + *
> + * We do this in standby mode only,
> + * so that this function won't return with a valid errmsg_buf.

Even if we do this while NOT in standby mode, ISTM that this function doesn't
return with a valid errmsg_buf because it's reset. So probably the comment
should be updated as follows?

-------------------------
We don't do this while not in standby mode because we don't need to retry
immediately if the page header is not valid. Instead, XLogReadRecord() is
responsible to check the page header.
-------------------------

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2021-09-06 17:34:17 Re: pgbench bug candidate: negative "initial connection time"
Previous Message Zhihong Yu 2021-09-06 16:46:37 Re: ORDER BY pushdowns seem broken in postgres_fdw