Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYDcP-00021w-LD for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Sep 2022 21:38:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oYDcN-0005yZ-9R for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Sep 2022 21:38:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYDcN-0005yF-0j for pgsql-hackers@lists.postgresql.org; Tue, 13 Sep 2022 21:38:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYDcG-0007us-Jn for pgsql-hackers@lists.postgresql.org; Tue, 13 Sep 2022 21:38:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 28DLclGi2402848; Tue, 13 Sep 2022 17:38:47 -0400 From: Tom Lane To: Michael Paquier cc: pgsql-hackers@lists.postgresql.org Subject: Re: pg_basebackup's --gzip switch misbehaves In-reply-to: References: <1400032.1662217889@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Tue, 13 Sep 2022 16:13:20 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2402846.1663105127.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 13 Sep 2022 17:38:47 -0400 Message-ID: <2402847.1663105127@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > Attached is the patch I am finishing with, consisting of: > - the removal of PG_COMPRESSION_OPTION_LEVEL. > - assigning a default compression level when nothing is specified in > the spec. > - a couple of complifications in pg_receivewal, pg_basebackup and the > backend code as there is no need to worry about the compression > level. This looks good to me. It seems simpler, and I concur that it fixes the described problem. I now see tmp_check/backup_gzip: total 3668 -rw-r-----. 1 postgres postgres 137756 Sep 13 17:29 backup_manifest -rw-r-----. 1 postgres postgres 3537499 Sep 13 17:29 base.tar.gz -rw-r-----. 1 postgres postgres 73989 Sep 13 17:29 pg_wal.tar.gz tmp_check/backup_gzip2: total 3168 -rw-r-----. 1 postgres postgres 137756 Sep 13 17:29 backup_manifest -rw-r-----. 1 postgres postgres 3083516 Sep 13 17:29 base.tar.gz -rw-r-----. 1 postgres postgres 17069 Sep 13 17:29 pg_wal.tar.gz tmp_check/backup_gzip3: total 3668 -rw-r-----. 1 postgres postgres 137756 Sep 13 17:29 backup_manifest -rw-r-----. 1 postgres postgres 3537517 Sep 13 17:29 base.tar.gz -rw-r-----. 1 postgres postgres 73988 Sep 13 17:29 pg_wal.tar.gz which looks sane: the gzip2 case should, and does, have better compression than the other two. BTW, this bit: diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_bas= ebackup/t/010_pg_basebackup.pl index 3d1a4ddd5c..40f1d3f7e2 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -860,9 +860,6 @@ SKIP: my $gzip_is_valid =3D system_log($gzip, '--test', @zlib_files, @zlib_files2, @zlib_files3); is($gzip_is_valid, 0, "gzip verified the integrity of compressed data"); - rmtree("$tempdir/backup_gzip"); - rmtree("$tempdir/backup_gzip2"); - rmtree("$tempdir/backup_gzip3"); } = # Test background stream process terminating before the basebackup has is something I tried along the way to diagnosing the problem, and it turns out to have exactly zero effect. The $tempdir is some temporary subdirectory of tmp_check that will get nuked at the end of the TAP test no matter what. So these rmtrees are merely making the evidence disappear a bit faster; it will anyway. What I did to diagnose the problem was this: @@ -860,9 +860,9 @@ SKIP: my $gzip_is_valid =3D system_log($gzip, '--test', @zlib_files, @zlib_files2, @zlib_files3)= ; is($gzip_is_valid, 0, "gzip verified the integrity of compressed data"= ); - rmtree("$tempdir/backup_gzip"); - rmtree("$tempdir/backup_gzip2"); - rmtree("$tempdir/backup_gzip3"); + system_log('mv', "$tempdir/backup_gzip", "tmp_check"); + system_log('mv', "$tempdir/backup_gzip2", "tmp_check"); + system_log('mv', "$tempdir/backup_gzip3", "tmp_check"); } = # Test background stream process terminating before the basebackup has which is not real clean, since then the files get left behind even on success, which I doubt we want either. Anyway, I have no objection to dropping the rmtrees, since they're pretty useless as the code stands. Just wanted to mention this issue for the archives. regards, tom lane