Re: Different compression methods for FPI

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, pgsql-hackers(at)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Different compression methods for FPI
Date: 2022-09-02 11:55:11
Message-ID: 20220902115511.GY31833@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jun 13, 2021 at 08:24:12PM -0500, Justin Pryzby wrote:
> In this patch series, I added compression information to the errcontext from
> xlog_block_info(), and allow specifying compression levels like zlib-2. I'll
> rearrange that commit earlier if we decide that's desirable to include.

4035cd5d4 added wal_compress=lz4 and
e9537321a added wal_compress=zstd

Since 4035cd5d4, pg_waldump has shown compression info (and walinspect
shows the same since 2258e76f9).

But if you try to replay WAL on a server which wasn't compiled with
support for the requisite compression methods, it's a bit crummy that it
doesn't include in the error message the reason *why* it failed to
restore the image, if that's caused by the missing compression method.

This hunk was from my patch in June, 2021, but wasn't included in the
final patches. This would include the compression info algorithm: 1)
when failing to apply WAL in rm_redo_error_callback(); and, 2) in
wal_debug.

< 2022-08-31 21:37:53.325 CDT >FATAL: failed to restore block image
< 2022-08-31 21:37:53.325 CDT >CONTEXT: WAL redo at 1201/1B931F50 for XLOG/FPI_FOR_HINT: ; blkref #0: rel 1663/16888/164320567, blk 8186 FPW, compression method: zstd

In addition to cases where someone re/compiles postgres locally, I guess this
would also improve the situation for PITR and standbys, which might reasonably
be run on a different OS, with different OS packages, or with postgres compiled
separately.

> diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
> index 17eeff0720..1ccc51575a 100644
> --- a/src/backend/access/transam/xlog.c
> +++ b/src/backend/access/transam/xlog.c
> @@ -10470,7 +10470,17 @@ xlog_block_info(StringInfo buf, XLogReaderState *record)
> rnode.spcNode, rnode.dbNode, rnode.relNode,
> blk);
> if (XLogRecHasBlockImage(record, block_id))
> - appendStringInfoString(buf, " FPW");
> + {
> + int compression =
> + BKPIMAGE_IS_COMPRESSED(record->blocks[block_id].bimg_info) ?
> + BKPIMAGE_COMPRESSION(record->blocks[block_id].bimg_info) : -1;
> + if (compression == -1)
> + appendStringInfoString(buf, " FPW");
> + else
> + appendStringInfo(buf, " FPW, compression method %d/%s",
> + compression, wal_compression_name(compression));
> + }
> +

Attachment Content-Type Size
0001-xlog_block_info-show-compression-method.patch text/x-diff 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2022-09-02 11:55:52 Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints
Previous Message Andrey Lepikhov 2022-09-02 11:08:55 Re: [POC] Allow flattening of subquery with a link to upper query