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
>From b38d020375481ae54aaf745bee58b7c1a074274b Mon Sep 17 00:00:00 2001 From: Li Jianping <jianping...@ww-it.cn> Date: Tue, 1 Jul 2025 17:42:48 +0800 Subject: [PATCH v1] Fix inconsistent LSN format in pg_waldump --- src/bin/pg_waldump/pg_waldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 51fb76efc48..5cf55be896d 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -555,7 +555,7 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record) XLogRecGetLen(record, &rec_len, &fpi_len); - printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ", + printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%X, prev %X/%X, ", desc->rm_name, rec_len, XLogRecGetTotalLen(record), XLogRecGetXid(record), -- 2.43.0