Re: pg_waldump error message fix

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: bossartn(at)amazon(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_waldump error message fix
Date: 2020-12-11 04:30:16
Message-ID: 20201211.133016.2215843397828552511.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 10 Dec 2020 18:47:58 +0000, "Bossart, Nathan" <bossartn(at)amazon(dot)com> wrote in
> Hi,
>
> I noticed that when pg_waldump finds an invalid record, the
> corresponding error message seems to point to the last valid record
> read.

Good catch!

> rmgr: ... lsn: 0/090E5AF8, prev 0/090E59D0, ...
> pg_waldump: fatal: error in WAL record at 0/90E5AF8: invalid record length at 0/90E5B30: wanted 24, got 0
>
> Should pg_waldump report currRecPtr instead of ReadRecPtr in the error
> message? With that, I see the following.
>
> rmgr: ... lsn: 0/090E5AF8, prev 0/090E59D0, ...
> pg_waldump: fatal: error in WAL record at 0/90E5B30: invalid record length at 0/90E5B30: wanted 24, got 0
>
> Here is the patch:
>
> diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
> index 31e99c2a6d..27da60e6db 100644
> --- a/src/bin/pg_waldump/pg_waldump.c
> +++ b/src/bin/pg_waldump/pg_waldump.c
> @@ -1110,8 +1110,8 @@ main(int argc, char **argv)
>
> if (errormsg)
> fatal_error("error in WAL record at %X/%X: %s",
> - (uint32) (xlogreader_state->ReadRecPtr >> 32),
> - (uint32) xlogreader_state->ReadRecPtr,
> + (uint32) (xlogreader_state->currRecPtr >> 32),
> + (uint32) xlogreader_state->currRecPtr,
> errormsg);
>
> XLogReaderFree(xlogreader_state);

currRecPtr is a private member of the struct (see the definition of
the struct XLogReaderState). We should instead use EndRecPtr outside
xlog reader.

regardes.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-12-11 05:21:57 Re: pg_waldump error message fix
Previous Message Michael Paquier 2020-12-11 04:17:35 Re: please update ps display for recovery checkpoint