pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: David Steele <david@pgmasters.net>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: Paul Guo <guopa@vmware.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Brown <michael.brown@discourse.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: should frontend tools use syncfs() ?
Date: Fri, 1 Sep 2023 12:58:10 -0500
Message-ID: <ZPImMi8smaPsXjGK@pryzbyj2023> (raw)
In-Reply-To: <20230729214010.GA189456@nathanxps13>
References: <20210930004340.GM831@telsasoft.com>
	<YVUz0Ay9KshniWBe@paquier.xyz>
	<20220413115412.GM26620@telsasoft.com>
	<20230729214010.GA189456@nathanxps13>

> +	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 +++





view thread (50+ messages)  latest in thread

Message-ID: <ZPImMi8smaPsXjGK@pryzbyj2023>
Permalink:  ../ZPImMi8smaPsXjGK@pryzbyj2023/
Also on:    postgresql.org/message-id/ZPImMi8smaPsXjGK@pryzbyj2023

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: pryzby@telsasoft.com, nathandbossart@gmail.com, michael@paquier.xyz, thomas.munro@gmail.com, david@pgmasters.net, masao.fujii@oss.nttdata.com, bruce@momjian.us, guopa@vmware.com, tgl@sss.pgh.pa.us, michael.brown@discourse.org
  Subject: Re: should frontend tools use syncfs() ?
  In-Reply-To: <ZPImMi8smaPsXjGK@pryzbyj2023>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox