]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix some issues with WAL segment opening for pg_receivewal --compress
authorMichael Paquier <michael@paquier.xyz>
Tue, 20 Jul 2021 03:12:54 +0000 (12:12 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 20 Jul 2021 03:12:54 +0000 (12:12 +0900)
commitb9a0de15eb2920956af64189cb87ecd7869bf60f
tree3d6771dd2761801451e6ad67401b7ea15a9a76d4
parentf2f459f182fc8b1af44e422e2324b7acd5ee2408
Fix some issues with WAL segment opening for pg_receivewal --compress

The logic handling the opening of new WAL segments was fuzzy when using
--compress if a partial, non-compressed, segment with the same base name
existed in the repository storing those files.  In this case, using
--compress would cause the code to first check for the existence and the
size of a non-compressed segment, followed by the opening of a new
compressed, partial, segment.  The code was accidentally working
correctly on most platforms as the buildfarm has proved, except
bowerbird where gzflush() could fail in this code path.  It is wrong
anyway to take the code path used pre-padding when creating a new
partial, non-compressed, segment, so let's fix it.

Note that this issue exists when users mix successive runs of
pg_receivewal with or without compression, as discovered with the tests
introduced by ffc9dda.

While on it, this refactors the code so as code paths that need to know
about the ".gz" suffix are down from four to one in walmethods.c, easing
a bit the introduction of new compression methods.  This addresses a
second issue where log messages generated for an unexpected failure
would not show the compressed segment name involved, which was
confusing, printing instead the name of the non-compressed equivalent.

Reported-by: Georgios Kokolatos
Discussion: https://postgr.es/m/YPDLz2x3o1aX2wRh@paquier.xyz
Backpatch-through: 10
src/bin/pg_basebackup/receivelog.c
src/bin/pg_basebackup/walmethods.c
src/bin/pg_basebackup/walmethods.h