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

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

Hi David,

Thanks for the patch. I reproduced all three cases on master with an
injection point, and v1 fixes them.

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. The restored cluster
then fails with

FATAL: incorrect size of file "pg_twophase/000000000000029C": 0
bytes

v1 cannot help here, since the open file really is empty. The
attached patch writes to a temp file and renames it into place.

Also, pg_verifybackup reports all of these broken backups as fine.

Thanks,
Shihao

Attachment Content-Type Size
nocfbot-twophase-temp-file-rename.txt text/plain 3.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Baji Shaik 2026-10-25 15:40:04 Avoid crashes on a concurrently dropped schema
Previous Message Baji Shaik 2026-10-25 15:23:54 Re: [PATCH] Fall back to serializing when parallel apply runs out of DSM segments