Re: Avoid truncated or zero-padded copies of replaced files in backups.

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: David Steele <david(at)pgbackrest(dot)org>
Cc: shihao zhong <zhong950419(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: Avoid truncated or zero-padded copies of replaced files in backups.
Date: 2026-10-26 04:20:57
Message-ID: at7VKZzOc-ctEq0Y@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Oct 25, 2026 at 06:01:09PM +0000, David Steele wrote:
> I confirmed with injection points as well but was not sure it was worth
> adding them to the patch since the fix is pretty straightforward.

If you want to post a patch with an injpoint test, please feel free to
post it to let someone else a way to reproduce a given problem.
They're useful for the purpose of reproducing an issue. Now I don't
think that this specific one is worth having in the tree, that feels
like a waste of test cycles.

>> I found one more file with the same problem. A checkpoint rewrites
>> pg_twophase files in place with O_TRUNC. If the backup copies one
>> right after the truncate, it gets an empty file.
>
> Good catch. My audit noticed this truncate but failed to note that the file
> would be accessed before WAL replay reconstructed it.

Ugh. F%$k.

> Since v1 can't help here it should probably be a separate patch. Or, we
> could include it as the first patch in a set with mine.
>
> Minor releases are soon but these bugs are so old that I'm not sure it makes
> sense to rush.

I would not mind acting on these. Both of you are pointing to two
different problems: they deserve two patches, one each.

I'd suggest to wait a bit for Robert a bit in case he'd like to
comment on the file size expectation of the on-disk stash advice file.
Saying that, could you adjust the 2PC file? I'd just fix that now and
be done with it..

> At this point it
> would be good to get some feedback from a committer to see how they want to
> proceed.

Done.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-10-26 04:22:15 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Michael Paquier 2026-10-26 04:13:13 Re: Avoid truncated or zero-padded copies of replaced files in backups.