Re: Fix pg_waldump to exit cleanly at end of WAL

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix pg_waldump to exit cleanly at end of WAL
Date: 2025-09-03 00:11:15
Message-ID: CAHGQGwGpE6oSL6R2PBZP5uEMQBVFAjikC9bomJ-pBRU+MQnJdg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 2, 2025 at 5:42 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> 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.

Can pg_waldump really distinguish between the end of WAL and corruption?

Looking back at past discussions, there seem similar patches and
conversations [1][2].
These might be useful references when considering this issue.

Regards,

[1] https://postgr.es/m/20200228.160100.2210969269596489579.horikyota.ntt@gmail.com
[2] https://postgr.es/m/674af9dc.050a0220.268e1c.4048@mx.google.com

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2025-09-03 00:14:18 Re: Use bool with synced field (src/include/replication/slot.h)
Previous Message torikoshia 2025-09-03 00:08:10 Re: COPY TO: provide hint when WHERE clause is used