From ec0274d6d73b329ce2e492843e364d88888569ce Mon Sep 17 00:00:00 2001 From: Nazir Bilal Yavuz Date: Thu, 17 Sep 2026 13:23:12 +0300 Subject: [PATCH v2 2/2] Fix WAL file selection in checksum rewind test Without an explicit WAL filename, pg_waldump determines the segment size from the first WAL-named directory entry. A preallocated segment with an uninitialized header can make this fail before the checkpoint is read. Pass the WAL filename recorded in backup_label to avoid depending on directory enumeration order. Use command_like() so command failures and stderr are checked rather than appearing only as an empty-output mismatch. --- src/test/modules/test_checksums/t/013_rewind.pl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/test/modules/test_checksums/t/013_rewind.pl b/src/test/modules/test_checksums/t/013_rewind.pl index 21715ace9f3..7e0ba87c8e2 100644 --- a/src/test/modules/test_checksums/t/013_rewind.pl +++ b/src/test/modules/test_checksums/t/013_rewind.pl @@ -151,15 +151,21 @@ $backup_label =~ /^CHECKPOINT LOCATION: ([0-9A-F\/]+)$/m or die "checkpoint location missing from backup_label"; is($1, $shutdown_ckpt, 'replay starts at the switchover checkpoint'); -($stdout, $stderr) = run_command( +# Specify the WAL file so that pg_waldump does not try to determine the +# segment size from an arbitrary, possibly preallocated, file in pg_wal. +$backup_label =~ /^START WAL LOCATION: [0-9A-F\/]+ \(file ([0-9A-F]{24})\)$/m + or die "WAL file name missing from backup_label"; +my $shutdown_wal = $1; + +command_like( [ 'pg_waldump', '-p' => $node_a->data_dir . '/pg_wal', - '-t' => 1, '-s' => $shutdown_ckpt, '-n' => 1, - ]); -like($stdout, qr/CHECKPOINT_SHUTDOWN/, + $shutdown_wal, + ], + qr/CHECKPOINT_SHUTDOWN/, 'last common checkpoint is a shutdown checkpoint'); # pg_rewind keeps the target's own checksum state in the control file it -- 2.43.0