Fix pg_waldump to exit cleanly at end of WAL

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Fix pg_waldump to exit cleanly at end of WAL
Date: 2025-09-02 08:42:24
Message-ID: CAEoWx2mkEG-=rQtSJ7LnPh8A_=tJ8=zFvQB30KhrXh41mzkokQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

I noticed a problem with pg_waldump. When "-e" is not specified, or given a
bigger number beyond the current LSN, pg_dump always print an error message
like:

```
chaol(at)ChaodeMacBook-Air cndb % pg_waldump -p pg_wal -s 0/2980DE10 -e
0/2980E680
<...omit some outputs...>
rmgr: Standby len (rec/tot): 50/ 50, tx: 0, lsn:
0/2980E468, prev 0/2980E3F0, desc: RUNNING_XACTS nextXid 866
latestCompletedXid 865 oldestRunningXid 866
pg_waldump: error: error in WAL record at 0/2980E468: invalid record length
at 0/2980E4A0: expected at least 24, got 0
```

The error message is kinda misleading and unnecessary. So I created a fix.

From the code comment in pg_waldump.c, the same change should be applied to
pg_walinspect. If this patch is accepted, I will then work on pg_walinspect
as well.

Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v1-0001-Fix-pg_waldump-to-exit-cleanly-at-end-of-WAL.patch application/octet-stream 1.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-09-02 08:56:26 Re: Fix use of variable after pfree
Previous Message Daniel Gustafsson 2025-09-02 08:24:34 Re: Increase OpenBSD CI task's RAM disk size