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 1qYGn7-001DJo-DI for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Aug 2023 02:06:45 +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 1qYGn5-00DEpt-Ub for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Aug 2023 02:06:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qYGn5-00DEmq-FI for pgsql-hackers@lists.postgresql.org; Tue, 22 Aug 2023 02:06:43 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qYGmx-000Frg-RB for pgsql-hackers@postgresql.org; Tue, 22 Aug 2023 02:06:42 +0000 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3a751d2e6ecso2966163b6e.0 for ; Mon, 21 Aug 2023 19:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692669995; x=1693274795; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=oaWqrIlyDuIWr7DEM9TA5JORLWDNct3Or6SLjyj72W0=; b=X/EsOmua5MxF+K+hL/owy0BmRuNwat9NEDbs4d8Uas9MRZQsnh8Mjs0i7nZy0ILwtW W0E5+HgD59SDclfUXrK2gTgY0EXvR3ALw5eH0ZBWBRu/5QlYqEAcxuVK1r/z1D5BaWL1 9LMvz63D10lQhgmpBy9HHRolX+su/ZRtziTxOFP97cEFeAJY/cZxUjw0gSx6OQelDkLh U5WG7/t+/yA78Usl/QnRnkajs/D0IQ40PFMYd1nJhpUNxvGasOTl9LfYHBGtM0+xkskq SUnLo5o3ImxoUAAIvZT/XnHuqGBBn5swt/YssCw7GyuItu9impGJPujODGEssd5yo5+H a9Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692669995; x=1693274795; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=oaWqrIlyDuIWr7DEM9TA5JORLWDNct3Or6SLjyj72W0=; b=MJTEcHxClpLCiVO9h3jHWdQCHUnKEREC0JJVU8rk/4sVnwHZb2YlxhmPBfCBbiEjUA ZyoYJvJytfFKouDjvi+TBA2FUp3HUbv/NAStXddZQfP0ErDXn6aZBadEUD178R1qm8j6 a+AmfOXE1/n6iMljzlwSoOTxvBL1o5WaFrkbN3lwsgXfLxXgLAafL7PKrGWP1xSkE/0B gG6BGWZhiI7TtNHuUC/hRzle2LMw6Ss5/KZWgJoXcoRL453S+vN3NOHgQEUWBrXJWYLz nf/g2vPJzodnUcTArIL7Iel0VJzAJXTtI0Vwd4UmZHPL2dlZu+JDVEzHpcq2hNjIh8Av 6UgQ== X-Gm-Message-State: AOJu0Yx9vOf7EGj81DcOmUnugjgz594MklNACNK7bvgYnYKWCftDMBQJ BJD+XKHqcYQFonrGWkqHbTI= X-Google-Smtp-Source: AGHT+IEkabcYeJkvzEHh06jSoynA+AN/QD520pEUwYqLraQRZ7HeAqf95epYUn4/luNYukOj6crn3g== X-Received: by 2002:a05:6808:3012:b0:3a7:249d:8733 with SMTP id ay18-20020a056808301200b003a7249d8733mr12607544oib.40.1692669995229; Mon, 21 Aug 2023 19:06:35 -0700 (PDT) Received: from nathanxps13 ([2600:1700:48f8:340f:2424:9658:77a9:73f4]) by smtp.gmail.com with ESMTPSA id q13-20020a056808200d00b003a09db4a54bsm4209628oiw.48.2023.08.21.19.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 19:06:34 -0700 (PDT) Date: Mon, 21 Aug 2023 19:06:32 -0700 From: Nathan Bossart To: Michael Paquier Cc: Justin Pryzby , Thomas Munro , David Steele , Fujii Masao , Bruce Momjian , Tom Lane , Michael Brown , pgsql-hackers@postgresql.org Subject: Re: should frontend tools use syncfs() ? Message-ID: <20230822020632.GA565843@nathanxps13> References: <20230731183946.GB537853@nathanxps13> <20230801163707.GA862840@nathanxps13> <20230808200606.GA1384393@nathanxps13> <20230816151705.GB2651383@nathanxps13> <20230818160111.GA189711@nathanxps13> <20230822014407.GA449131@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="cNdxnHkX5QqsyA0e" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Aug 22, 2023 at 10:50:01AM +0900, Michael Paquier wrote: > On Mon, Aug 21, 2023 at 06:44:07PM -0700, Nathan Bossart wrote: >> I'm hoping there's a simpler path forward here. pg_rewind only needs the >> following lines from fd.h: >> >> /* Filename components */ >> #define PG_TEMP_FILES_DIR "pgsql_tmp" >> #define PG_TEMP_FILE_PREFIX "pgsql_tmp" >> >> Maybe we could move these to file_utils.h instead. WDYT? > > I guess so.. At the same time, something can be said about > pg_checksums that redeclares PG_TEMP_FILE_PREFIX and PG_TEMP_FILES_DIR > because it does not want to include fd.h and its sync routines. This would look something like the attached patch. I think this is nicer. With this patch, we don't have to choose between including fd.h or redefining the macros in the frontend code. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --cNdxnHkX5QqsyA0e Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-move-PG_TEMP_FILE-macros-to-file_utils.h.patch" From af40f64933b5d8829b7e1641ce57e4ef8fd5a2c2 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Mon, 21 Aug 2023 19:05:14 -0700 Subject: [PATCH 1/1] move PG_TEMP_FILE* macros to file_utils.h --- src/backend/backup/basebackup.c | 2 +- src/backend/storage/file/fileset.c | 1 + src/bin/pg_checksums/pg_checksums.c | 10 ---------- src/bin/pg_rewind/filemap.c | 2 +- src/include/common/file_utils.h | 4 ++++ src/include/storage/fd.h | 4 ---- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/backend/backup/basebackup.c b/src/backend/backup/basebackup.c index 45be21131c..5d66014499 100644 --- a/src/backend/backup/basebackup.c +++ b/src/backend/backup/basebackup.c @@ -25,6 +25,7 @@ #include "commands/defrem.h" #include "common/compression.h" #include "common/file_perm.h" +#include "common/file_utils.h" #include "lib/stringinfo.h" #include "miscadmin.h" #include "nodes/pg_list.h" @@ -37,7 +38,6 @@ #include "storage/bufpage.h" #include "storage/checksum.h" #include "storage/dsm_impl.h" -#include "storage/fd.h" #include "storage/ipc.h" #include "storage/reinit.h" #include "utils/builtins.h" diff --git a/src/backend/storage/file/fileset.c b/src/backend/storage/file/fileset.c index e9951b0269..84cae32548 100644 --- a/src/backend/storage/file/fileset.c +++ b/src/backend/storage/file/fileset.c @@ -25,6 +25,7 @@ #include "catalog/pg_tablespace.h" #include "commands/tablespace.h" +#include "common/file_utils.h" #include "common/hashfn.h" #include "miscadmin.h" #include "storage/ipc.h" diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 19eb67e485..9011a19b4e 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -52,16 +52,6 @@ typedef enum PG_MODE_ENABLE } PgChecksumMode; -/* - * Filename components. - * - * XXX: fd.h is not declared here as frontend side code is not able to - * interact with the backend-side definitions for the various fsync - * wrappers. - */ -#define PG_TEMP_FILES_DIR "pgsql_tmp" -#define PG_TEMP_FILE_PREFIX "pgsql_tmp" - static PgChecksumMode mode = PG_MODE_CHECK; static const char *progname; diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c index bd5c598e20..58280d9abc 100644 --- a/src/bin/pg_rewind/filemap.c +++ b/src/bin/pg_rewind/filemap.c @@ -27,12 +27,12 @@ #include #include "catalog/pg_tablespace_d.h" +#include "common/file_utils.h" #include "common/hashfn.h" #include "common/string.h" #include "datapagemap.h" #include "filemap.h" #include "pg_rewind.h" -#include "storage/fd.h" /* * Define a hash table which we can use to store information about the files diff --git a/src/include/common/file_utils.h b/src/include/common/file_utils.h index b7efa1226d..dd1532bcb0 100644 --- a/src/include/common/file_utils.h +++ b/src/include/common/file_utils.h @@ -46,4 +46,8 @@ extern ssize_t pg_pwritev_with_retry(int fd, extern ssize_t pg_pwrite_zeros(int fd, size_t size, off_t offset); +/* Filename components */ +#define PG_TEMP_FILES_DIR "pgsql_tmp" +#define PG_TEMP_FILE_PREFIX "pgsql_tmp" + #endif /* FILE_UTILS_H */ diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index 6791a406fc..aea30c0622 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -195,8 +195,4 @@ extern int durable_unlink(const char *fname, int elevel); extern void SyncDataDirectory(void); extern int data_sync_elevel(int elevel); -/* Filename components */ -#define PG_TEMP_FILES_DIR "pgsql_tmp" -#define PG_TEMP_FILE_PREFIX "pgsql_tmp" - #endif /* FD_H */ -- 2.25.1 --cNdxnHkX5QqsyA0e--