]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix pg_waldump/t/001_basic.pl with BSD tar on ZFS.
authorThomas Munro <tmunro@postgresql.org>
Wed, 1 Apr 2026 01:02:39 +0000 (14:02 +1300)
committerThomas Munro <tmunro@postgresql.org>
Wed, 1 Apr 2026 01:37:01 +0000 (14:37 +1300)
The new test fails with an error about a missing WAL file on that
stack, because it is archived in GNU tar's --sparse --format=posix
format.  BSD tar uses that format by default, unlike GNU tar itself, and
ZFS triggers it by implicitly creating sparse files when it sees a lot
of zeroes.

The problem will surely also affect real users of the new tar support in
pg_waldump (commit b15c1513) and pg_verifybackup (commit b3cf461b3) on
such systems.  Ideas under discussion, but for now the test is made to
pass by disabling sparse file detection in BSD tar.

Diagnosed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/1624716.1774736283%40sss.pgh.pa.us

src/bin/pg_waldump/t/001_basic.pl

index 8bb8fa225f6fceae755af4b8a525c9392e4cabbe..ce1f6aa30c028615cc6b0082983d0c8cce15595b 100644 (file)
@@ -11,6 +11,15 @@ use Test::More;
 use List::Util qw(shuffle);
 
 my $tar = $ENV{TAR};
+my @tar_c_flags;
+
+# By default, bsdtar archives sparse files in GNU tar's --format=posix --sparse
+# format, so pg_waldump can't find files that ZFS has decided to store with
+# holes.  Turn that off.
+if (system("$tar --no-read-sparse -c - /dev/null > /dev/null") == 0)
+{
+  push(@tar_c_flags, "--no-read-sparse");
+}
 
 program_help_ok('pg_waldump');
 program_version_ok('pg_waldump');
@@ -346,7 +355,7 @@ sub generate_archive
        # move into the WAL directory before archiving files
        my $cwd = getcwd;
        chdir($directory) || die "chdir: $!";
-       command_ok([$tar, $compression_flags, $archive, @files]);
+       command_ok([$tar, @tar_c_flags, $compression_flags, $archive, @files]);
        chdir($cwd) || die "chdir: $!";
 }