pg_waldump error message fix

From: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_waldump error message fix
Date: 2020-12-10 18:47:58
Message-ID: 2B4510B2-3D70-4990-BFE3-0FE64041C08A@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2020-12-10 18:49:39 Re: Proposed patch for key managment
Previous Message Bruce Momjian 2020-12-10 18:42:36 Re: Proposed patch for key managment