At Thu, 10 Dec 2020 18:47:58 +0000, "Bossart, Nathan" <bossa...@amazon.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


Reply via email to