pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix some issues with WAL segment opening for pg_receivewal --com
Date: Tue, 20 Jul 2021 03:13:55 +0000
Message-ID: <E1m5gCh-0005pD-0g@gemulon.postgresql.org> (raw)

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

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/795a9166e2e16058256e90fdc2a3af8ee726ca30

Modified Files
--------------
src/bin/pg_basebackup/receivelog.c | 13 ++++---
src/bin/pg_basebackup/walmethods.c | 79 +++++++++++++++++++++++++++++---------
src/bin/pg_basebackup/walmethods.h |  9 +++++
3 files changed, 78 insertions(+), 23 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1m5gCh-0005pD-0g@gemulon.postgresql.org>
Permalink:  ../E1m5gCh-0005pD-0g@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1m5gCh-0005pD-0g@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Fix some issues with WAL segment opening for pg_receivewal --com
  In-Reply-To: <E1m5gCh-0005pD-0g@gemulon.postgresql.org>
  References: <E1m5gCh-0005pD-0g@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox