Re: Fix detection of truncated zstd-compressed backups

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Osama Abdul Qader <osamaabdulqader(dot)cs(at)gmail(dot)com>
Subject: Re: Fix detection of truncated zstd-compressed backups
Date: 2026-08-13 01:47:24
Message-ID: 3664E105-4512-4BD2-99A7-0F5C25EBB173@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Aug 13, 2026, at 05:56, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> I have two minor comment for v5, otherwise it looks good to me:

Hi Zsolt,

Thanks a lot for reviewing.

>
> +typedef enum
> +{
> + STREAM_NEW,
> + STREAM_HAS_DATA,
> + STREAM_FINISHED,
> +} pg_stream_state;
> +
>
> This is duplicated in two files, wouldn't be astreamer.h a better place for it?

I think this makes sense. Plus your second comment, this enum can be shared by all 3 astreamers. I moved it to astreamer.h and renamed it to astreamer_decompression_state.

>
> + if (!mystreamer->stream_finished)
> + pg_fatal("could not decompress data: compressed stream is incomplete");
> +
>
> The other two checks distinguish empty from incomplete, is this
> difference intended?

I do not think that is intentional. My initial implementation did not check for an empty stream, and gzip uses a different pattern from zstd and LZ4, which is probably why Daniel initially added the empty-stream check only to zstd and lz4.

I have now added the same check to gzip so that all three astreamers are consistent.

PFA v6: addressed Zsolt’s comments.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v6-0001-Fix-detection-of-truncated-compressed-backups.patch application/octet-stream 9.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-08-13 02:11:20 Re: Re-read conindid under the referenced table's lock in the RI fast path
Previous Message Bharath Rupireddy 2026-08-13 01:30:00 Re: [PATCH] Release replication slot on error in SQL-callable slot functions