Re: pg_basebackup's --gzip switch misbehaves
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2022-09-04T05:20:52Z
Lists: pgsql-hackers
On Sat, Sep 03, 2022 at 11:11:29AM -0400, Tom Lane wrote:
> It makes sense that base.tar.gz is compressed a little better with
> --gzip than with level-1 compression, but why is pg_wal.tar.gz not
> compressed at all? It looks like the problem probably boils down to
> which of "-1" and "0" means "default behavior" vs "no compression",
> with different code layers interpreting that differently. I can't
> find exactly where that's happening, but I did manage to stop the
> failures with this crude hack:
There is a distinction coming in pg_basebackup.c from the way we
deparse the compression specification and the default compression
level that should be assigned if there is no level directly specified
by the user. It seems to me that the error comes from this code in
BaseBackup() when we are under STREAM_WAL (default):
if (client_compress->algorithm == PG_COMPRESSION_GZIP)
{
wal_compress_algorithm = PG_COMPRESSION_GZIP;
wal_compress_level =
(client_compress->options & PG_COMPRESSION_OPTION_LEVEL)
!= 0 ? client_compress->level : 0;
ffd5365 has missed that wal_compress_level should be set to
Z_DEFAULT_COMPRESSION if there is nothing set in the compression
spec for a zlib build. pg_receivewal.c enforces that already.
> That's not right as a real fix, because it would have the effect
> that "--compress gzip:0" would also invoke default compression,
> whereas what it should do is produce the uncompressed output
> we're actually getting. Both cases have compression_level == 0
> by the time we reach here, though.
Nope, that would not be right.
> BTW, I'm fairly astonished that anyone would have thought that three
> complete pg_basebackup cycles testing essentially-identical options
> were a good use of developer time and buildfarm cycles from here to
> eternity. Even if digging into it did expose a bug, the test case
> deserves little credit for that, because it entirely failed to call
> attention to the problem. I had to whack the script pretty hard
> just to get it to not delete the evidence.
The introduction of the compression specification has introduced a lot
of patterns where we expect or not expect compression to happen, and
on top of that this needs to be careful about backward-compatibility.
--
Michael
Commits
-
Make PG_TEST_NOCLEAN work for temporary directories in TAP tests
- 45cfa87e9c56 11.21 landed
- af36c13a7e92 12.16 landed
- b102e80ab822 13.12 landed
- c8987ea90cf2 14.9 landed
- 4b15868b698a 15.4 landed
- c24e9ef330ac 16.0 landed
- 8c12838001c2 17.0 landed
-
doc: document the TAP test environment variables
- c4421550fb57 16.0 landed
-
doc: update metacpan.org links to avoid redirects
- 5f80cd287c29 16.0 landed
-
Use min/max bounds defined by Zstd for compression level
- ade925e1693a 15.0 landed
- 18ac08f0b42d 16.0 landed
-
Fix incorrect value for "strategy" with deflateParams() in walmethods.c
- a9e99ff6b4ac 10.23 landed
- f01cc02259df 11.18 landed
- adb371c9cd95 12.13 landed
- a94576c377b7 13.9 landed
- 4b529f4697f3 14.6 landed
- b3c630cc9230 15.0 landed
- b447d6075db8 16.0 landed
-
Simplify handling of compression level with compression specifications
- 53332eacaff6 15.0 landed
- f352e2d08ac0 16.0 landed