Remove wal_sync_method=fsync_writethrough on Windows.

The "fsync" level already flushes drive write caches on Windows (as does
"fdatasync"), so it only confuses matters to have an apparently higher
level that isn't actually different at all.

That leaves "fsync_writethrough" only for macOS, where it actually does
something different.

Reviewed-by: Magnus Hagander <magnus@hagander.net>
Discussion: https://postgr.es/m/CA%2BhUKGJ2CG2SouPv2mca2WCTOJxYumvBARRcKPraFMB6GSEMcA%40mail.gmail.com
This commit is contained in:
Thomas Munro 2023-07-14 11:59:07 +12:00
parent aea7fe33fb
commit d0c28601ef
4 changed files with 5 additions and 18 deletions

View File

@ -109,9 +109,8 @@
<literal>open_datasync</literal> (the default), write caching can be disabled <literal>open_datasync</literal> (the default), write caching can be disabled
by unchecking <literal>My Computer\Open\<replaceable>disk drive</replaceable>\Properties\Hardware\Properties\Policies\Enable write caching on the disk</literal>. by unchecking <literal>My Computer\Open\<replaceable>disk drive</replaceable>\Properties\Hardware\Properties\Policies\Enable write caching on the disk</literal>.
Alternatively, set <varname>wal_sync_method</varname> to Alternatively, set <varname>wal_sync_method</varname> to
<literal>fdatasync</literal> (NTFS only), <literal>fsync</literal> or <literal>fdatasync</literal> (NTFS only) or <literal>fsync</literal>,
<literal>fsync_writethrough</literal>, which prevent which prevent write caching.
write caching.
</para> </para>
</listitem> </listitem>

View File

@ -399,7 +399,7 @@ pg_fsync(int fd)
#endif #endif
/* #if is to skip the sync_method test if there's no need for it */ /* #if is to skip the sync_method test if there's no need for it */
#if defined(HAVE_FSYNC_WRITETHROUGH) && !defined(FSYNC_WRITETHROUGH_IS_FSYNC) #if defined(HAVE_FSYNC_WRITETHROUGH)
if (sync_method == SYNC_METHOD_FSYNC_WRITETHROUGH) if (sync_method == SYNC_METHOD_FSYNC_WRITETHROUGH)
return pg_fsync_writethrough(fd); return pg_fsync_writethrough(fd);
else else
@ -437,9 +437,7 @@ pg_fsync_writethrough(int fd)
{ {
if (enableFsync) if (enableFsync)
{ {
#ifdef WIN32 #if defined(F_FULLFSYNC)
return _commit(fd);
#elif defined(F_FULLFSYNC)
return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0; return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0;
#else #else
errno = ENOSYS; errno = ENOSYS;

View File

@ -605,9 +605,7 @@ signal_cleanup(SIGNAL_ARGS)
static int static int
pg_fsync_writethrough(int fd) pg_fsync_writethrough(int fd)
{ {
#ifdef WIN32 #if defined(F_FULLFSYNC)
return _commit(fd);
#elif defined(F_FULLFSYNC)
return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0; return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0;
#else #else
errno = ENOSYS; errno = ENOSYS;

View File

@ -84,14 +84,6 @@
/* Windows doesn't have fsync() as such, use _commit() */ /* Windows doesn't have fsync() as such, use _commit() */
#define fsync(fd) _commit(fd) #define fsync(fd) _commit(fd)
/*
* For historical reasons, we allow setting wal_sync_method to
* fsync_writethrough on Windows, even though it's really identical to fsync
* (both code paths wind up at _commit()).
*/
#define HAVE_FSYNC_WRITETHROUGH
#define FSYNC_WRITETHROUGH_IS_FSYNC
#define USES_WINSOCK #define USES_WINSOCK
/* /*