Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f900a79

Browse files
committed
Default to wal_sync_method=fdatasync on FreeBSD.
FreeBSD 13 gained O_DSYNC, which would normally cause wal_sync_method to choose open_datasync as its default value. That may not be a good choice for all systems, and performs worse than fdatasync in some scenarios. Let's preserve the existing default behavior for now. Like commit 576477e, which did the same for Linux, back-patch to all supported releases. Discussion: https://postgr.es/m/CA%2BhUKGLsAMXBQrCxCXoW-JsUYmdOL8ALYvaX%3DCrHqWxm-nWbGA%40mail.gmail.com
1 parent 2c8b42b commit f900a79

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/src/sgml/config.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2928,7 +2928,7 @@ include_dir 'conf.d'
29282928
Not all of these choices are available on all platforms.
29292929
The default is the first method in the above list that is supported
29302930
by the platform, except that <literal>fdatasync</literal> is the default on
2931-
Linux. The default is not necessarily ideal; it might be
2931+
Linux and FreeBSD. The default is not necessarily ideal; it might be
29322932
necessary to change this setting or other aspects of your system
29332933
configuration in order to create a crash-safe configuration or
29342934
achieve optimal performance.

src/backend/utils/misc/postgresql.conf.sample

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
#wal_sync_method = fsync # the default is the first option
207207
# supported by the operating system:
208208
# open_datasync
209-
# fdatasync (default on Linux)
209+
# fdatasync (default on Linux and FreeBSD)
210210
# fsync
211211
# fsync_writethrough
212212
# open_sync

src/include/port/freebsd.h

+9
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
/* src/include/port/freebsd.h */
2+
3+
/*
4+
* Set the default wal_sync_method to fdatasync. xlogdefs.h's normal rules
5+
* would prefer open_datasync on FreeBSD 13+, but that is not a good choice on
6+
* many systems.
7+
*/
8+
#ifdef HAVE_FDATASYNC
9+
#define PLATFORM_DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
10+
#endif

0 commit comments

Comments
 (0)