HiĀ Anthonin,

On 12/12/2025 10:39, Anthonin Bonnefoy wrote:

With this patch, pg_waldump will now have the following output when reading a file with an invalid header: pg_waldump: error: could not find a valid record after D80/5C000000: invalid magic number D116 in WAL segment 0000001400000D8000000017, LSN D80/5C000000, offset 0

I've picked up the review for your patch.

Attached is a failing test that reproduces the issue. Have I got it right? We can consider using it to validate your patch then.

--
Thanks,
Mircea Cadariu
From 56f5a2512275f2bc1086d846aa8d63b8d7166ca0 Mon Sep 17 00:00:00 2001
From: Mircea Cadariu <[email protected]>
Date: Tue, 3 Feb 2026 15:49:26 +0000
Subject: [PATCH v1] Add pg_waldump test for invalid WAL page magic error
 message

---
 src/bin/pg_waldump/t/003_error_message.pl | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 src/bin/pg_waldump/t/003_error_message.pl

diff --git a/src/bin/pg_waldump/t/003_error_message.pl 
b/src/bin/pg_waldump/t/003_error_message.pl
new file mode 100644
index 0000000000..7992d18f1b
--- /dev/null
+++ b/src/bin/pg_waldump/t/003_error_message.pl
@@ -0,0 +1,22 @@
+use strict;
+use warnings FATAL => 'all';
+use PostgreSQL::Test::Utils;
+use Test::More;
+
+my $tempdir = PostgreSQL::Test::Utils::tempdir();
+my $walfile = "$tempdir/000000010000000000000000";
+
+open(my $fh, '>', $walfile) or die "Cannot create $walfile: $!";
+binmode($fh);
+print $fh pack('vvVQ<VVQ<VV',
+    0xD116, 0x0002, 1, 0, 0, 0, 12345678901234, 16*1024*1024, 8192);
+print $fh "\0" x (8192 - 40);
+close($fh);
+
+command_fails_like(
+    [ 'pg_waldump', '--start=0/28', $walfile ],
+    qr/invalid magic number.*D116/i,
+    'detailed error message shown for invalid WAL page magic'
+);
+
+done_testing();
-- 
2.39.5 (Apple Git-154)

Reply via email to