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 1sKE9Q-008xAZ-NF for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Jun 2024 09:32:16 +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 1sKE8Q-003MG6-B3 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Jun 2024 09:31:15 +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 1sKE8Q-003MFy-0D for pgsql-hackers@lists.postgresql.org; Thu, 20 Jun 2024 09:31:14 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sKE8O-002cTS-2m for pgsql-hackers@postgresql.org; Thu, 20 Jun 2024 09:31:14 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a6ef793f4b8so61186366b.1 for ; Thu, 20 Jun 2024 02:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1718875870; x=1719480670; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=cHe1217u+RfP31rmbnSWqAxQuGOuHlMJCGX6ya/9Sog=; b=eebpMk5LxZtsywPeaX53N+0jwmulLnGhQ0qjxpQRI8PQYMEad9W7N+brYF9zc3Qru0 Pso7PIT8Hzyx7TOUIrM1XqziBlp/VJiZqX6ie/AqvwiuuKKwt8qZNWAfdIFr0eFuUy7r koEvykUGOrTalwiaeo6Rn26HJVDIP8sMP+8gF4k71adhLzA+vZVtUBmaPyYINUrRMQts cK32AMJzWMPhaozctVU2f9/DMwWZ6y1jcL5N9g0zAPmV3fVrjKszJlNpJgmlj7pBiuND hJZQTuqXc3T9WupbPksA8ZaV888hJCTTIJjrRVpn3TGfYQDho4YV9Cb0vuejCo91yrez 5Xkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718875870; x=1719480670; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cHe1217u+RfP31rmbnSWqAxQuGOuHlMJCGX6ya/9Sog=; b=tRuz1Sc9DNC8W8moJAqLk+HbMzbZwy7S721K36n0DNI+ezRZjSKiPjfd+klZUOnXX7 mxOPfkVo9lC4s8uBOA53urBJYZwRD1rHgEj0IMlYl6Q/bk4rgtr2Hfwl9r1HQKOGWczK s43lYgOTuNc08Bhc3gCacyUy6dEkmi7Q1JzOYzqhM+F3PTbNmvzqo3LbxeoNkrIbAmFU hMsI9K5+wySx14/wPDDedNgZHvVyxwlmu/wzkHgIDO5JIC+Lx/FBCxs2S0SkTGc72KIx aIBdIJcvDwz1Qjchy7dy+EgrIne1sB6T/yG9/rkXfcPd2a8wkaFloHVWtjk2zPxpCpGE gEOQ== X-Forwarded-Encrypted: i=1; AJvYcCXvw1ByTfy0YImGJ7kfrl4WHUJJcoA2hH3wsu4EoSILytr5dvp0H3GhdxXr8+kFod21fQ71sDVl0SdM6hVsC7+UbBQ/MMuj16xMU7ZA X-Gm-Message-State: AOJu0YzXEciCt+HPqys6yz3yVTNTsBRz2AsQmSEif83C5XR3zTD/5xOj k26+IGl5FsLw8eGGU0zaMJLXJMWNYuUkoWwR3JwcL7S3ej6B7YowvF5a4GX/frBxahLAbd8kePg = X-Google-Smtp-Source: AGHT+IFAinsSsxMpqQOt0HvekHVFQdlKV8kowPSixUIE7nZezEtAa4fcHh9O9Cp3sJFtQtCuepDN3g== X-Received: by 2002:a17:907:1b0b:b0:a6e:372c:cc5e with SMTP id a640c23a62f3a-a6fab77a1bamr328940566b.61.1718875870267; Thu, 20 Jun 2024 02:31:10 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56f98959sm749000166b.204.2024.06.20.02.31.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Jun 2024 02:31:09 -0700 (PDT) Message-ID: Date: Thu, 20 Jun 2024 11:31:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_combinebackup --clone doesn't work To: Peter Eisentraut , pgsql-hackers References: <48da4a1f-ccd9-4988-9622-24f37b1de2b4@eisentraut.org> Content-Language: en-US From: Tomas Vondra In-Reply-To: <48da4a1f-ccd9-4988-9622-24f37b1de2b4@eisentraut.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/20/24 07:55, Peter Eisentraut wrote: > 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.) > Seems like my bug, I guess :-( Chances are the original patches had the include, but it got lost during refactoring or something. Anyway, will fix shortly. > 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.) > Yeah. The ifdef forest got rather hard to navigate. > 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} }) > For ad hoc testing? Sure, but that won't work on platforms without the clone support, right? > 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?) > Yeah, this sounds like a good way to do this. Is there a good reason to have multiple different variables, one for each tool, or should we have a single PG_TEST_COPY_MODE affecting all the places? > 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. > I vaguely recall this might have been discussed in the thread about adding cloning to pg_combinebackup, but I don't recall the details why we didn't adopt the pg_uprade way. But we can revisit that, IMO. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company