Hi,

I noticed that when pg_waldump finds an invalid record, the
corresponding error message seems to point to the last valid record
read.

    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);

Nathan

Reply via email to