Re: Return pg_control from pg_backup_stop().

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

On Fri, Oct 23, 2026 at 06:47:24PM +0300, Heikki Linnakangas wrote:
> Looks good to me.

Apologies for not following closely what you have been doing lately in
this area, David. I should have followed, but well..

+void
+backup_control_file(uint8 *controlFile)
+{
+ ControlFileData controlData;
+
+ LWLockAcquire(ControlFileLock, LW_SHARED);
+ memcpy(&controlData, ControlFile, sizeof(ControlFileData));
+ LWLockRelease(ControlFileLock);
[...]
/* ... and pg_control after everything else. */
- if (lstat(XLOG_CONTROL_FILE, &statbuf) != 0)
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not stat file \"%s\": %m",
- XLOG_CONTROL_FILE)));
- sendFile(sink, XLOG_CONTROL_FILE, XLOG_CONTROL_FILE, &statbuf,
- false, InvalidOid, InvalidOid,
- InvalidRelFileNumber, 0, &manifest, 0, NULL, 0);
+ backup_control_file(controlFile);
+ sendFileWithContent(sink, XLOG_CONTROL_FILE,
+ (char *) controlFile, PG_CONTROL_FILE_SIZE,
+ &manifest);

Yep, that's clearly something that should be backpatched, at quick
glance. Heikki, are you planning to take care of this part?
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Masahiko Sawada 2026-10-24 05:17:49 Re: [PG19] Promotion hangs behind a backend blocked on a stuck client