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: Add support for LZ4 compression in pg_receivewal
Date: Fri, 05 Nov 2021 02:34:25 +0000
Message-ID: <E1mip3h-0003id-Ss@gemulon.postgresql.org> (raw)

Add support for LZ4 compression in pg_receivewal

pg_receivewal gains a new option, --compression-method=lz4, available
when the code is compiled with --with-lz4.  Similarly to gzip, this
gives the possibility to compress archived WAL segments with LZ4.  This
option is not compatible with --compress.

The implementation uses LZ4 frames, and is compatible with simple lz4
commands.  Like gzip, using --synchronous ensures that any data will be
flushed to disk within the current .partial segment, so as it is
possible to retrieve as much WAL data as possible even from a
non-completed segment (this requires completing the partial file with
zeros up to the WAL segment size supported by the backend after
decompression, but this is the same as gzip).

The calculation of the streaming start LSN is able to transparently find
and check LZ4-compressed segments.  Contrary to gzip where the
uncompressed size is directly stored in the object read, the LZ4 chunk
protocol does not store the uncompressed data by default.  There is
contentSize that can be used with LZ4 frames by that would not help if
using an archive that includes segments compressed with the defaults of
a "lz4" command, where this is not stored.  So, this commit has taken
the most extensible approach by decompressing the already-archived
segment to check its uncompressed size, through a blank output buffer in
chunks of 64kB (no actual performance difference noticed with 8kB, 16kB
or 32kB, and the operation in itself is actually fast).

Tests have been added to verify the creation and correctness of the
generated LZ4 files.  The latter is achieved by the use of command
"lz4", if found in the environment.

The tar-based WAL method in walmethods.c, used now only by
pg_basebackup, does not know yet about LZ4.  Its code could be extended
for this purpose.

Author: Georgios Kokolatos
Reviewed-by: Michael Paquier, Jian Guo, Magnus Hagander, Dilip Kumar
Discussion: https://postgr.es/m/ZCm1J5vfyQ2E6dYvXz8si39HQ2gwxSZ3IpYaVgYa3lUwY88SLapx9EEnOf5uEwrddhx2twG7zYKjVeuP...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/babbbb595d2322da095a1e6703171b3f1f2815cb

Modified Files
--------------
doc/src/sgml/ref/pg_receivewal.sgml          |   8 +-
src/Makefile.global.in                       |   1 +
src/bin/pg_basebackup/Makefile               |   1 +
src/bin/pg_basebackup/pg_receivewal.c        | 158 +++++++++++++++++++++++++-
src/bin/pg_basebackup/t/020_pg_receivewal.pl |  72 ++++++++++--
src/bin/pg_basebackup/walmethods.c           | 160 ++++++++++++++++++++++++++-
src/bin/pg_basebackup/walmethods.h           |   1 +
7 files changed, 388 insertions(+), 13 deletions(-)



Message-ID: <E1mip3h-0003id-Ss@gemulon.postgresql.org>
Permalink:  ../E1mip3h-0003id-Ss@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mip3h-0003id-Ss@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: Add support for LZ4 compression in pg_receivewal
  In-Reply-To: <E1mip3h-0003id-Ss@gemulon.postgresql.org>
  References: <E1mip3h-0003id-Ss@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