Re: Return pg_control from pg_backup_stop().

From: solai v <solai(dot)cdac(at)gmail(dot)com>
To: David Steele <david(at)pgbackrest(dot)org>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: Return pg_control from pg_backup_stop().
Date: 2026-07-14 10:27:44
Message-ID: CAF0whueXubW3F4aaHOzMTbz92smb1bQ1MY_MiqXnmh-t1JmeYQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

On Wed, Jul 8, 2026 at 2:49 PM David Steele <david(at)pgbackrest(dot)org> wrote:
>
> On 4/13/26 21:55, David Steele wrote:
> >
> > I have withdrawn this patch. If anybody wants to pick it up in the
> > future I'll be happy to rebase it but I think two years is long enough
> > to maintain a patch that is not getting traction.
> I would like to revive this but focus on the first patch for now and
> drop the second patch from consideration.
>
> The patch now implements only the new flag for pgcontrol and wires this
> logic into basebackup. It has the additional benefit of guaranteeing
> that the base backup contains a non-torn version of pgcontrol.
>
> I know everyone was really busy in March but now that things are a bit
> calmer I'd like to revisit.
>
> Heikki, Robert, Andres, Fujii -- any objections or comments? I believe
> Michael is on board with the feature (this part, at least) but he very
> sensibly would like to have some consensus.

I reviewed and tested this patch on my PostgreSQL 20devel tree. The
patch applied cleanly and built successfully without any issues. As
part of the testing, I first attempted to reproduce the issue using a
backup created with pg_backup_start()/pg_backup_stop() followed by a
filesystem copy of the data directory. After restoring the backup and
deleting backup_label, the server started successfully.
While in between, I found that backupLabelRequired is set through
backup_control_file(), due to which the above workflow does not
exercise the new code path introduced by this patch. I then repeated
the test using pg_basebackup. After creating a physical backup, I
verified using pg_controldata that the backed-up pg_control contained:

Backup label required: yes.

I continued with the testing like restoring the backup, removing the
backup_label file, and attempting to start the restored cluster. The
PostgreSQL refused to start and reported the errors as expected:

FATAL: could not find backup_label required for recovery
HINT: restore the backup_label file that was created during the backup.

This behavior is consistent with the intended purpose of the patch and
discussions thereby preventing recovery from a pg_basebackup backup
when the required backup_label file is missing. And also I reviewed
the implementation and verified that the backupLabelRequired field is
added to ControlFileData, set while preparing the copied pg_control in
backup_control_file(), checked during recovery, and cleared after
successful recovery. Overall, the patch behaves as intended and looks
good to me.

Regards,
Solai

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan Gonzalez V. 2026-07-14 11:06:17 Re: Coverage (lcov) failing with inconsistent error in versions 2.x
Previous Message Daniel Gustafsson 2026-07-14 10:06:02 Re: [PATCH] pg_upgrade: add --initdb option to create the new cluster automatically