Skip to content

Commit d0c2860

Browse files
committed
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
1 parent aea7fe3 commit d0c2860

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

doc/src/sgml/wal.sgml

+2-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@
109109
<literal>open_datasync</literal> (the default), write caching can be disabled
110110
by unchecking <literal>My Computer\Open\<replaceable>disk drive</replaceable>\Properties\Hardware\Properties\Policies\Enable write caching on the disk</literal>.
111111
Alternatively, set <varname>wal_sync_method</varname> to
112-
<literal>fdatasync</literal> (NTFS only), <literal>fsync</literal> or
113-
<literal>fsync_writethrough</literal>, which prevent
114-
write caching.
112+
<literal>fdatasync</literal> (NTFS only) or <literal>fsync</literal>,
113+
which prevent write caching.
115114
</para>
116115
</listitem>
117116

src/backend/storage/file/fd.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ pg_fsync(int fd)
399399
#endif
400400

401401
/* #if is to skip the sync_method test if there's no need for it */
402-
#if defined(HAVE_FSYNC_WRITETHROUGH) && !defined(FSYNC_WRITETHROUGH_IS_FSYNC)
402+
#if defined(HAVE_FSYNC_WRITETHROUGH)
403403
if (sync_method == SYNC_METHOD_FSYNC_WRITETHROUGH)
404404
return pg_fsync_writethrough(fd);
405405
else
@@ -437,9 +437,7 @@ pg_fsync_writethrough(int fd)
437437
{
438438
if (enableFsync)
439439
{
440-
#ifdef WIN32
441-
return _commit(fd);
442-
#elif defined(F_FULLFSYNC)
440+
#if defined(F_FULLFSYNC)
443441
return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0;
444442
#else
445443
errno = ENOSYS;

src/bin/pg_test_fsync/pg_test_fsync.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,7 @@ signal_cleanup(SIGNAL_ARGS)
605605
static int
606606
pg_fsync_writethrough(int fd)
607607
{
608-
#ifdef WIN32
609-
return _commit(fd);
610-
#elif defined(F_FULLFSYNC)
608+
#if defined(F_FULLFSYNC)
611609
return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0;
612610
#else
613611
errno = ENOSYS;

src/include/port/win32_port.h

-8
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,6 @@
8484
/* Windows doesn't have fsync() as such, use _commit() */
8585
#define fsync(fd) _commit(fd)
8686

87-
/*
88-
* For historical reasons, we allow setting wal_sync_method to
89-
* fsync_writethrough on Windows, even though it's really identical to fsync
90-
* (both code paths wind up at _commit()).
91-
*/
92-
#define HAVE_FSYNC_WRITETHROUGH
93-
#define FSYNC_WRITETHROUGH_IS_FSYNC
94-
9587
#define USES_WINSOCK
9688

9789
/*

0 commit comments

Comments
 (0)