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.94.2) (envelope-from ) id 1sKB1Q-008erX-Ar for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Jun 2024 06:11:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sKB0O-00011v-Eb for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Jun 2024 06:10:45 +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.94.2) (envelope-from ) id 1sKB0M-00010I-UR for pgsql-hackers@lists.postgresql.org; Thu, 20 Jun 2024 06:10:44 +0000 Received: from wfout8-smtp.messagingengine.com ([64.147.123.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKAlO-002ajA-KS for pgsql-hackers@postgresql.org; Thu, 20 Jun 2024 05:55:21 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id C0ED61C000A3 for ; Thu, 20 Jun 2024 01:55:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 20 Jun 2024 01:55:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :subject:subject:to:to; s=fm1; t=1718862910; x=1718949310; bh=uQ 4iHcMEY7S+sHzc74sivajPrqsIGe2Ew/U/rI2xgCk=; b=AP8VYaprUZkI/jyg8H OQx5WmfR5AB6b0O2Q36dBF9ZexOQq3zirwUuFm56R38JShu/kDYCAlpkf0WFegDp S86hs4sWY4V/0rjmHqydHkasbJ43opEMwFxJ1OpIBSV8a4CCcVt6W+cxl6VRKVmQ K9nynDiFi087ZzPbuv9kDJKWJURLw52wYM36Lf51D1ZbxzK9i4PX0Absnq5rw0dP v5EAw8rHKEnpBTW1RSmPmeFQpHQDUsWX02RhJGiFH2uLPQizg6KPaWSrywkGhz1H DNDdBZ9tQtUQDvSQof/+DrfZJ0dUB7lc3Ya9NeaEZmxQFvaloDrLhABsGvuL38FU JJqg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1718862910; x=1718949310; bh=uQ4iHcMEY7S+sHzc74sivajPrqsI Ge2Ew/U/rI2xgCk=; b=EiOzmxxI7WpcEx2a9ETDjR+Pk+Cav471l4ac3PXeYl7Q VEh6Th45j3P/cWXzeFYlpUCXymKKeVISGZqYDEOEylpAMjSznBaquBaELVxzDBEv kmsqMEnp1QAYwR2pOaKGBz3mjAvLASeJARIXWBF1SpT4w7KV5tbcKydE6OfFxzAD EB118LjEMofFyF9j0yoA9fFzskcmu822L2H19D6oPFVO8nHEy3GZqJQ9bX+X0slh LMR19Ez+5XDOjcEM7MQ2Abq2WbG3ymwWAdfaCQtCC1bFqbYX6RVtUAmZ1I+nX4EO OuNfi3Ia0/yUfbizi86ka+K9mQvhG+xfhG4XknNpnw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefuddguddtvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfhffuvfgtgfesthejre dttddvjeenucfhrhhomheprfgvthgvrhcugfhishgvnhhtrhgruhhtuceophgvthgvrhes vghishgvnhhtrhgruhhtrdhorhhgqeenucggtffrrghtthgvrhhnpeffteevuddtfeelje evkeegfeetffeuueeggfefgeekvdduleevleehudffvdevheenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrsegvihhsvghnthhrrg huthdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 20 Jun 2024 01:55:09 -0400 (EDT) Message-ID: <48da4a1f-ccd9-4988-9622-24f37b1de2b4@eisentraut.org> Date: Thu, 20 Jun 2024 07:55:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Peter Eisentraut Subject: pg_combinebackup --clone doesn't work To: pgsql-hackers Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The pg_combinebackup --clone option currently doesn't work at all. Even on systems where it should it be supported, you'll always get a "file cloning not supported on this platform" error. The reason is this checking code in pg_combinebackup.c: #if (defined(HAVE_COPYFILE) && defined(COPYFILE_CLONE_FORCE)) || \ (defined(__linux__) && defined(FICLONE)) if (opt.dry_run) pg_log_debug("would use cloning to copy files"); else pg_log_debug("will use cloning to copy files"); #else pg_fatal("file cloning not supported on this platform"); #endif The problem is that this file does not include the appropriate OS header files that would define COPYFILE_CLONE_FORCE or FICLONE, respectively. The same problem also exists in copy_file.c. (That one has the right header file for macOS but still not for Linux.) This should be pretty easy to fix up, and we should think about some ways to refactor this to avoid repeating all these OS-specific things a few times. (The code was copied from pg_upgrade originally.) But in the short term, how about some test coverage? You can exercise the different pg_combinebackup copy modes like this: diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm index 83f385a4870..7e8dd024c82 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -848,7 +848,7 @@ sub init_from_backup } local %ENV = $self->_get_env(); - my @combineargs = ('pg_combinebackup', '-d'); + my @combineargs = ('pg_combinebackup', '-d', '--clone'); if (exists $params{tablespace_map}) { while (my ($olddir, $newdir) = each %{ $params{tablespace_map} }) We could do something like what we have for pg_upgrade, where we can use the environment variable PG_TEST_PG_UPGRADE_MODE to test the different copy modes. We could turn this into a global option. (This might also be useful for future work to use file cloning elsewhere, like in CREATE DATABASE?) Also, I think it would be useful for consistency if pg_combinebackup had a --copy option to select the default mode, like pg_upgrade does.