1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-28 18:48:04 +03:00

Rework compression options of pg_receivewal

pg_receivewal includes since cada1af the option --compress, to allow the
compression of WAL segments using gzip, with a value of 0 (the default)
meaning that no compression can be used.

This commit introduces a new option, called --compression-method, able
to use as values "none", the default, and "gzip", to make things more
extensible.  The case of --compress=0 becomes fuzzy with this option
layer, so we have made the choice to make pg_receivewal return an error
when using "none" and a non-zero compression level, meaning that the
authorized values of --compress are now [1,9] instead of [0,9].  Not
specifying --compress with "gzip" as compression method makes
pg_receivewal use the default of zlib instead (Z_DEFAULT_COMPRESSION).

The code in charge of finding the streaming start LSN when scanning the
existing archives is refactored and made more extensible.  While on it,
rename "compression" to "compression_level" in walmethods.c, to reduce
the confusion with the introduction of the compression method, even if
the tar method used by pg_basebackup does not rely on the compression
method (yet, at least), but just on the compression level (this area
could be improved more, actually).

This is in preparation for an upcoming patch that adds LZ4 support to
pg_receivewal.

Author: Georgios Kokolatos
Reviewed-by: Michael Paquier, Jian Guo, Magnus Hagander, Dilip Kumar,
Robert Haas
Discussion: https://postgr.es/m/ZCm1J5vfyQ2E6dYvXz8si39HQ2gwxSZ3IpYaVgYa3lUwY88SLapx9EEnOf5uEwrddhx2twG7zYKjVeuP5MwZXCNPybtsGouDsAD1o2L_I5E=@pm.me
This commit is contained in:
Michael Paquier
2021-11-04 11:10:31 +09:00
parent 581055c32f
commit d62bcc8b07
8 changed files with 231 additions and 103 deletions

View File

@@ -263,15 +263,36 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--compression-method=<replaceable class="parameter">level</replaceable></option></term>
<listitem>
<para>
Enables compression of write-ahead logs using the specified method.
Supported values <literal>gzip</literal>, and
<literal>none</literal>.
</para>
<para>
The suffix <filename>.gz</filename> will automatically be added to
all filenames when using <literal>gzip</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-Z <replaceable class="parameter">level</replaceable></option></term>
<term><option>--compress=<replaceable class="parameter">level</replaceable></option></term>
<listitem>
<para>
Enables gzip compression of write-ahead logs, and specifies the
compression level (0 through 9, 0 being no compression and 9 being best
compression). The suffix <filename>.gz</filename> will
automatically be added to all filenames.
Specifies the compression level (<literal>1</literal> through
<literal>9</literal>, <literal>1</literal> being worst compression
and <literal>9</literal> being best compression) for WAL segments
compressed with <application>gzip</application>.
</para>
<para>
This option requires <option>--compression-method</option> to be
specified with <literal>gzip</literal>.
</para>
</listitem>
</varlistentry>