[PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

Поиск
Список
Период
Сортировка
Искать

[PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
shihao zhong <zhong950419@gmail.com>
Дата:
Вложения:
Hi hackers,

I used Opus to analyze the new features in PG 19.
It found that pg_verifybackup never finishes on a tar-format
backup taken with pg_basebackup -Ft -z.

I had manually proved that by hand.

On REL_19_STABLE:

  pg_basebackup -D /tmp/verify_targz.66809/bk -c fast -Ft -z
  pg_verifybackup /tmp/verify_targz.66809/bk
  # still running after 20 s, killing pg_waldump
  pg_verifybackup: error: WAL parsing failed for timeline 1
  pg_verifybackup -n /tmp/verify_targz.66809/bk
  backup successfully verified
  rewrite pg_wal.tar.gz as a single gzip member
  pg_verifybackup /tmp/verify_targz.66809/bk
  backup successfully verified

With WAL streaming, pg_basebackup ends the gzip stream before and
after every tar header, so pg_wal.tar.gz is a chain of gzip members.
astreamer_gzip_decompressor_content() loops until avail_in is zero.
After the first member inflate() keeps returning Z_STREAM_END and
takes no more input, so the loop never ends. The loop runs in
pg_waldump, and pg_verifybackup waits for it.

Patches attached. 0001 calls inflateReset() when inflate() returns
Z_STREAM_END, so the next member is read. 0002 adds a --gzip case to
the tar test in 007_wal.pl and is optional.

Thanks,
Shihao

Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Chao Li <li.evan.chao@gmail.com>
Дата:


> On Oct 6, 2026, at 09:15, shihao zhong  wrote:
> 
> Hi hackers,
> 
> I used Opus to analyze the new features in PG 19.
> It found that pg_verifybackup never finishes on a tar-format
> backup taken with pg_basebackup -Ft -z.
> 
> I had manually proved that by hand.
> 
> On REL_19_STABLE:
> 
>   pg_basebackup -D /tmp/verify_targz.66809/bk -c fast -Ft -z
>   pg_verifybackup /tmp/verify_targz.66809/bk
>   # still running after 20 s, killing pg_waldump
>   pg_verifybackup: error: WAL parsing failed for timeline 1
>   pg_verifybackup -n /tmp/verify_targz.66809/bk
>   backup successfully verified
>   rewrite pg_wal.tar.gz as a single gzip member
>   pg_verifybackup /tmp/verify_targz.66809/bk
>   backup successfully verified
> 
> With WAL streaming, pg_basebackup ends the gzip stream before and
> after every tar header, so pg_wal.tar.gz is a chain of gzip members.
> astreamer_gzip_decompressor_content() loops until avail_in is zero.
> After the first member inflate() keeps returning Z_STREAM_END and
> takes no more input, so the loop never ends. The loop runs in
> pg_waldump, and pg_verifybackup waits for it.
> 
> Patches attached. 0001 calls inflateReset() when inflate() returns
> Z_STREAM_END, so the next member is read. 0002 adds a --gzip case to
> the tar test in 007_wal.pl and is optional.
> 
> Thanks,
> Shihao
> 
> 

Look like a dup of https://www.postgresql.org/message-id/5962B878-C43D-4EBC-9E95-1F945CE5E586%40gmail.com.

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






Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
shihao zhong <zhong950419@gmail.com>
Дата:
Hi Chao,

I took a look at the code and I think we are solving different problems.

This is not the truncated backup problem in [1]. Head with v9-0001 still 

Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 6 Oct 2026, at 03:48, shihao zhong  wrote:

> I took a look at the code and I think we are solving different problems.

I concur that this is a separate issue.  Today I returned to looking at the
truncation patchset and I am including this fix in that review effort.

--
Daniel Gustafsson



Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Melanie Plageman <melanieplageman@gmail.com>
Дата:
On Wed, Oct 7, 2026 at 7:44 AM Daniel Gustafsson  wrote:
>
> > On 6 Oct 2026, at 03:48, shihao zhong  wrote:
>
> > I took a look at the code and I think we are solving different problems.
>
> I concur that this is a separate issue.  Today I returned to looking at the
> truncation patchset and I am including this fix in that review effort.

Should this have a 19 open item?

- Melanie


Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 7 Oct 2026, at 17:44, Melanie Plageman  wrote:
> On Wed, Oct 7, 2026 at 7:44 AM Daniel Gustafsson  wrote:

>> I concur that this is a separate issue.  Today I returned to looking at the
>> truncation patchset and I am including this fix in that review effort.
> 
> Should this have a 19 open item?

That's probably a good idea.

--
Daniel Gustafsson



Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Chao Li <li.evan.chao@gmail.com>
Дата:


> On Oct 7, 2026, at 19:44, Daniel Gustafsson  wrote:
> 
>> On 6 Oct 2026, at 03:48, shihao zhong  wrote:
> 
>> I took a look at the code and I think we are solving different problems.
> 
> I concur that this is a separate issue.  Today I returned to looking at the
> truncation patchset and I am including this fix in that review effort.
> 
> --
> Daniel Gustafsson
> 

Sorry for the confusion. I was on vacation and didn’t look into the patch closely.

This seems to be an old bug that couldn’t be triggered before PG19 (b15c1513984 added tar support to pg_waldump). So, I agree with Melanie that this should be an 19 open item.

The patch calls inflateReset() after each member finishes, allowing decompression to continue with the next member, which looks like a correct fix to me.

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






Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:

On 2026-10-07 We 8:48 PM, Chao Li wrote:
>
>> On Oct 7, 2026, at 19:44, Daniel Gustafsson  wrote:
>>
>>> On 6 Oct 2026, at 03:48, shihao zhong  wrote:
>>> I took a look at the code and I think we are solving different problems.
>> I concur that this is a separate issue.  Today I returned to looking at the
>> truncation patchset and I am including this fix in that review effort.
>>
>> --
>> Daniel Gustafsson
>>
> Sorry for the confusion. I was on vacation and didn’t look into the patch closely.
>
> This seems to be an old bug that couldn’t be triggered before PG19 (b15c1513984 added tar support to pg_waldump). So, I agree with Melanie that this should be an 19 open item.
>
> The patch calls inflateReset() after each member finishes, allowing decompression to continue with the next member, which looks like a correct fix to me.
>

Yes, looks good to me. I will commit later today.


cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com



Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:

On 2026-10-08 Th 10:14 AM, Andrew Dunstan wrote:
>
> On 2026-10-07 We 8:48 PM, Chao Li wrote:
>>
>>> On Oct 7, 2026, at 19:44, Daniel Gustafsson  wrote:
>>>
>>>> On 6 Oct 2026, at 03:48, shihao zhong  wrote:
>>>> I took a look at the code and I think we are solving different 
>>>> problems.
>>> I concur that this is a separate issue.  Today I returned to looking 
>>> at the
>>> truncation patchset and I am including this fix in that review effort.
>>>
>>> -- 
>>> Daniel Gustafsson
>>>
>> Sorry for the confusion. I was on vacation and didn’t look into the 
>> patch closely.
>>
>> This seems to be an old bug that couldn’t be triggered before PG19 
>> (b15c1513984 added tar support to pg_waldump). So, I agree with 
>> Melanie that this should be an 19 open item.
>>
>> The patch calls inflateReset() after each member finishes, allowing 
>> decompression to continue with the next member, which looks like a 
>> correct fix to me.
>>
>
> Yes, looks good to me. I will commit later today.
>
>

On re-reading I see Daniel is going to address it.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com



Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 8 Oct 2026, at 19:28, Andrew Dunstan  wrote:
> On 2026-10-08 Th 10:14 AM, Andrew Dunstan wrote:

>> Yes, looks good to me. I will commit later today.
> 
> On re-reading I see Daniel is going to address it.

I had this patched staged along with a few more compression related fixes but
as I found some issues to fix in those I broke this one out and pushed
separately to ensure it gets into 19 in time for RC1.  Pushed and backpatched.

--
Daniel Gustafsson



Re: [PG19]pg_verifybackup never finishes on a gzip-compressed tar backup

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:

On 2026-10-08 Th 4:03 PM, Daniel Gustafsson wrote:
>> On 8 Oct 2026, at 19:28, Andrew Dunstan  wrote:
>> On 2026-10-08 Th 10:14 AM, Andrew Dunstan wrote:
>>> Yes, looks good to me. I will commit later today.
>> On re-reading I see Daniel is going to address it.
> I had this patched staged along with a few more compression related fixes but
> as I found some issues to fix in those I broke this one out and pushed
> separately to ensure it gets into 19 in time for RC1.  Pushed and backpatched.
>

Thanks, Daniel!


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com



FAQ