Re: Different compression methods for FPI - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: Different compression methods for FPI
Date
Msg-id 20220902115511.GY31833@telsasoft.com
Whole thread Raw
In response to Re: Different compression methods for FPI  (Justin Pryzby <pryzby@telsasoft.com>)
Responses Re: Different compression methods for FPI
List 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

pgsql-hackers by date:

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