Inconsistent LSN format in pg_waldump output

Japin Li <japinli@hotmail.com>

From: Japin Li <japinli@hotmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-01T09:45:55Z
Lists: pgsql-hackers

Attachments

Hi, all

I've noticed an inconsistency in the LSN format printed by pg_waldump,
specifically concerning the lsn: and prev fields in the output.

    $ pg_waldump /tmp/pgdata02/pg_wal/00000001000000000000000A 2>/dev/null |grep 'AB10260'
    rmgr: XLOG        len (rec/tot):    114/   114, tx:          0, lsn: 0/0AB10260, prev 0/0AB10228, desc: CHECKPOINT_SHUTDOWN redo 0/AB10260; ...
                                                                         ^                                                           ^

In the output above, the LSN 0/AB10260 and 0/0AB10260 refer to the same logical
LSN, but are presented with a different number of leading zeros in the lower
32-bit part.

Upon further investigation, I grepped the source code for the format specifier
used:

    $ grep '%X\/%08X' -rn src/
    src/bin/pg_waldump/pg_waldump.c:558:    printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",

This inconsistency, while minor, could be confusing when cross-referencing
LSNs within pg_waldump's own output or when parsing it programmatically.

-- 
Regards,
Japin Li

Commits

  1. Fix a couple more places in docs for pg_lsn change

  2. Adapt pg_upgrade test to pg_lsn output format difference

  3. Standardize LSN formatting by zero padding