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 1qc8PW-00DxCM-Ue for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Sep 2023 17:58:22 +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 1qc8PV-00GMvo-3E for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Sep 2023 17:58:20 +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 1qc8PU-00GMvd-PW for pgsql-hackers@lists.postgresql.org; Fri, 01 Sep 2023 17:58:20 +0000 Received: from charmander.telsasoft.com ([50.244.222.1] helo=pryzbyj2023.telsasoft) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qc8PN-002OAB-FY for pgsql-hackers@postgresql.org; Fri, 01 Sep 2023 17:58:19 +0000 Received: by pryzbyj2023.telsasoft (Postfix, from userid 1000) id 54B57141C0; Fri, 1 Sep 2023 12:58:10 -0500 (CDT) Date: Fri, 1 Sep 2023 12:58:10 -0500 From: Justin Pryzby To: Nathan Bossart Cc: Michael Paquier , Thomas Munro , David Steele , Fujii Masao , Bruce Momjian , Paul Guo , Tom Lane , Michael Brown , pgsql-hackers@postgresql.org Subject: Re: should frontend tools use syncfs() ? Message-ID: References: <20210930004340.GM831@telsasoft.com> <20220413115412.GM26620@telsasoft.com> <20230729214010.GA189456@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230729214010.GA189456@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > + if (!user_opts.sync_method) > + user_opts.sync_method = pg_strdup("fsync"); why pstrdup? > +parse_sync_method(const char *optarg, SyncMethod *sync_method) > +{ > + if (strcmp(optarg, "fsync") == 0) > + *sync_method = SYNC_METHOD_FSYNC; > +#ifdef HAVE_SYNCFS > + else if (strcmp(optarg, "syncfs") == 0) > + *sync_method = SYNC_METHOD_SYNCFS; > +#endif > + else > + { > + pg_log_error("unrecognized sync method: %s", optarg); > + return false; > + } This should probably give a distinct error when syncfs is not supported than when it's truely recognized. The patch should handle pg_dumpall, too. Note that /bin/sync doesn't try to de-duplicate, it does just what you tell it. $ strace -e openat,syncfs,fsync sync / / / -f ... openat(AT_FDCWD, "/", O_RDONLY|O_NONBLOCK) = 3 syncfs(3) = 0 openat(AT_FDCWD, "/", O_RDONLY|O_NONBLOCK) = 3 syncfs(3) = 0 openat(AT_FDCWD, "/", O_RDONLY|O_NONBLOCK) = 3 syncfs(3) = 0 +++ exited with 0 +++