Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wCIh9-001qh9-2m for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 14:55:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wCIh8-007PHg-0h for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 14:55:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wCIh7-007PHY-2l for pgsql-hackers@lists.postgresql.org; Mon, 13 Apr 2026 14:55:22 +0000 Received: from buffalo.tulip.relay.mailchannels.net ([23.83.218.24]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wCIh6-00000000r1R-29LZ for pgsql-hackers@postgresql.org; Mon, 13 Apr 2026 14:55:22 +0000 X-Sender-Id: hostingeremail|x-authuser|david@pgbackrest.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E96D8180AF3; Mon, 13 Apr 2026 14:55:17 +0000 (UTC) Received: from de-fra-smtpout4.hostinger.io (trex-green-9.trex.outbound.svc.cluster.local [100.103.51.188]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 221C618313D; Mon, 13 Apr 2026 14:55:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; d=mailchannels.net; s=arc-2022; cv=none; t=1776092117; b=zCWzSwpnbAPuJxH2VygCDB7vBhvkL4h4u7O8lgxzMLS1A27V8VnSb9h29F8KE3VruG5OKt spLjMCvGRlu0EsHYkuXDMFmtHeZXI2OxLHw/GmdIz0XI7b8YhbZ21uphrEq31fw7fu8hSX cfcmlVK6hQ4pptBaVacdhX4yavsoR4Ktd70vH1w8X3VcHmh0f9wkhNj9EQ++3B9QDyMzas a6+/h4p6IlQ0045f4ufq6IUqVlfrVmEZJHnODWmH7fC9uIVJ5V5if4QA48ifWZW7o2VqQC +n8xsfltQt7DbZMVblTRuCXxJJfMizRfmaLvfph3DsfP5X4SOMHOfxLlrHszpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1776092117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BwuOnyN98jEqi+AU+IYgorXiGSLrBx4rmpiUZD2mQXs=; b=haO48lwCuqPt6jc+c+/xx4BfdZ8i0PLRlrmXayZFNkMWKgQj0d7OpzbM6ukiDZ0Pg2uUVy 1uy31aGmRZvkjcoKnw/Rh75joRBfYD9CwKCmypA76p2bB+jAi+7+2TSGvQYxAxUf/1+e1J GPybb+VGtW63ctfjEaQ8D139erfGqPLWsItCfWVL1DZr3LYTTCSylwQtlaCygX/vfces0F fxpFu/eWgwjxGpxCDkpANuoX0dbM5fZPFLR4vN8HsSEFZlk/TkjkaBA/P/unVS655IhGIJ Qv2be9YqQ54k5UuMjY3Wj4Ctb4XVf6HB54EP3GNtkIC1aXol3bRbVD7gq8w3ZQ== ARC-Authentication-Results: i=1; rspamd-7d86dcc447-c98lz; auth=pass smtp.auth=hostingeremail smtp.mailfrom=david@pgbackrest.org X-Sender-Id: hostingeremail|x-authuser|david@pgbackrest.org X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|david@pgbackrest.org X-MailChannels-Auth-Id: hostingeremail X-Zesty-Grain: 07a67cd251d8405d_1776092117796_2824715536 X-MC-Loop-Signature: 1776092117796:1551335246 X-MC-Ingress-Time: 1776092117795 Received: from de-fra-smtpout4.hostinger.io (de-fra-smtpout4.hostinger.io [148.222.55.14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.103.51.188 (trex/7.1.5); Mon, 13 Apr 2026 14:55:17 +0000 Received: from [10.5.0.2] (unknown [157.97.134.188]) (Authenticated sender: david@pgbackrest.org) by smtp.hostinger.com (smtp.hostinger.com) with ESMTPSA id 4fvVnW27Njz44J3; Mon, 13 Apr 2026 14:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgbackrest.org; s=hostingermail1; t=1776092114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BwuOnyN98jEqi+AU+IYgorXiGSLrBx4rmpiUZD2mQXs=; b=tkfGhgm8w1WRY0qfgoxHHon/jVXRAZA4Hij6hc2HAfcPTh99pqatd/ibn/I6TWzKOc1KQ0 NOXWvnykKUETL05LdebnzQIUFlvpESiMFuBAdAcLtDNdNSLuLXEGW6cI66EHSNXFGK/ZkQ JtoxVbfhYZ0SP1v12FdjdKLeNB03M86Nbj9ZLIKsHxpqR5UfmzADDjh6/2/aw19nj/JwL4 Qtl6w55ZxLfR54vtMo7htW0742OVY5cEtyzVtPH7Eu5jIEJ3A6bi5kv/GHXJAWbI9413k3 treC3M4Wekxpo4cJS2WW7YBSeIVaqCJ549nd3B/Dhmt++ZtnFe0jGcwGBFzDdA== Message-ID: <4193dcbc-591e-44bb-816c-43b4ae70d31c@pgbackrest.org> MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Return pg_control from pg_backup_stop(). From: David Steele To: Michael Paquier Cc: Haibo Yan , Pg Hackers , Heikki Linnakangas , Robert Haas , Andres Freund , Fujii Masao References: <8b8aa673-fcef-4e14-a05d-0885283ef1b8@pgbackrest.org> <17DC1346-0CDE-4E39-B110-3D6FB0797AC6@gmail.com> <7F7B289B-F94F-42C2-9E54-6A689C0D64BB@gmail.com> <1800c83c-264a-4183-9da5-ac78e25849a8@pgbackrest.org> <3b23e3b7-53d2-4784-b482-05cca3327acb@pgbackrest.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 13 Apr 2026 14:55:10 +0000 (UTC) X-CM-Analysis: v=2.4 cv=Ceda56rl c=1 sm=1 tr=0 ts=69dd03d2 a=Lax1bL0kA26ynyipiA+iYg==:117 a=Lax1bL0kA26ynyipiA+iYg==:17 a=IkcTkHD0fZMA:10 a=wzDvhLhE_aKZO9kRFxAA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-CM-Envelope: MS4xfG1zUhkTmVL8LAi3yKAslZbdA48wX76IzKUOijlmCglciQ/I+rwy5FJrGIqDwkQovT5QrTXGEec69q/SWhICkJ1UJMaZXkHOKHlwIbCxb8h6hEIi75Ow UOzhRRP+DrGrjF8RTeklMj9uNSWxyj28QP5Jho2CrNBiFqD8oczXUZcRE6wVQZ6H7B0B6nfOA/3/8GTfTtuo5cvRebMzP0APafAQsbIKNC3XA6owQ/TzYOc8 8eoX4vR/xcIjVVikzH7Ut3k9uPnX+o2cpw7OX2XUPf6X0Lsp0IdiriEarzAoBO+DKJV57knSgzgopT9kMqNOdrAbEjnSGrOpVGpPw2Tik21xIVmp2fq5p+ne L4EmslSQbySItEa+kMvagt2WjWqI2w== X-AuthUser: david@pgbackrest.org List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/18/26 19:26, David Steele wrote: > On 3/18/26 15:26, Michael Paquier wrote: >> On Wed, Mar 18, 2026 at 07:35:47AM +0000, David Steele wrote: >>> You are correct -- the copy of pg_control needs to happen before >>> do_pg_backup_stop(). An older version of this patch saved pg_control in >>> backup_state which made the prior location safe. However, I missed >>> moving >>> this code when I moved pg_control out of backup_state. Code review to >>> the >>> rescue. >> >> Right.  I am wondering also if the final result would not be better >> without 0002, actually, focusing only on the "simpler" base backup >> case through the replication protocol, and you are making a good case >> in mentioning it as not absolutely mandatory for base backups that are >> taken through the SQL functions.  One could always tweak the flag >> manually in the control file based on the contents taken from the data >> folder.  That's more hairy than writing the entire file, for sure, >> still possible. > > Getting even 01 into PG19 would be a great outcome. This would solve the > problem of torn pg_control and deleted backup labels for any backups > made with pg_basebackup and that's going to cover a *lot* of cases. > > Established third-party backup solutions that are not based on > pg_basebackup are generally able to manipulate pg_control so that's not > as much of a concern, perhaps. It does raise the barrier of entry for > new backup software if they need to learn to read and validate > pg_control to avoid a torn copy and set the flag. Patch 02 solves that > problem in a general way so I still think it adds value for the > ecosystem -- but we could always discuss that in the PG20 cycle. > > Whatever gets committed for PG19 I'll write a followup patch to describe > the hazards of reading pg_control and generally how to get a good copy. > However, this will be complicated enough that the best answer will > likely be to use pg_basebackup or some other reputable backup software. > I don't love this -- I feel like the low-level interface should be > usable with such hazards. 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. We are left with the issue that pg_basebackup backups may contain a torn copy of pg_control. At the least this should be documented. It would also be a good idea to document that utilizing the low-level backup interface requires validating the checksum in pg_control to avoid a torn copy. This is non-trivial but certainly doable. Regards, -David