Skip site navigation (1) Skip section navigation (2)

[PATCH] Revert default wal_sync_method to fdatasync on Linux 2.6.33+

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] Revert default wal_sync_method to fdatasync on Linux 2.6.33+
Date: 2010-11-05 17:23:35
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Hi list,

PostgreSQL's default settings change when built with Linux kernel
headers 2.6.33 or newer. As discussed on the pgsql-performance list,
this causes a significant performance regression:

NB! I am not proposing to change the default -- to the contrary --
this patch restores old behavior. Users might be in for a nasty
performance surprise when re-building their Postgres with newer Linux
headers (as was I), so I propose that this change should be made in
all supported releases.

-- commit message --
Revert default wal_sync_method to fdatasync on Linux 2.6.33+

Linux kernel headers from 2.6.33 (and later) change the behavior of the
O_SYNC flag. Previously O_SYNC was aliased to O_DSYNC, which caused
PostgreSQL to use fdatasync as the default instead.

Starting with kernels 2.6.33 and later, the definitions of O_DSYNC and
O_SYNC differ. When built with headers from these newer kernels,
PostgreSQL will default to using open_datasync. This patch reverts the
Linux default to fdatasync, which has had much more testing over time
and also significantly better performance.
-- end commit message --

Earlier kernel headers defined O_SYNC and O_DSYNC to 0x1000
2.6.33 and later define O_SYNC=0x101000 and O_DSYNC=0x1000 (since old
behavior on most FS-es was always equivalent to POSIX O_DSYNC)

More details at:;a=commit;h=6b2f3d1f769be5779b479c37800229d9a4809fc3

Currently PostgreSQL's include/access/xlogdefs.h defaults to using
open_datasync when O_SYNC != O_DSYNC, otherwise fdatasync is used.

Since other platforms might want to default to fdatasync in the
future, too, I defined a new PLATFORM_DEFAULT_SYNC_METHOD constant in
include/port/linux.h. I don't know if this is the best way to do it.


Attachment: 0001-Revert-default-wal_sync_method-to-fdatasync-on-Linux.patch
Description: text/x-patch (2.4 KB)


pgsql-hackers by date

Next:From: Daniel FarinaDate: 2010-11-05 17:36:38
Subject: Re: ALTER TABLE ... IF EXISTS feature?
Previous:From: Tom LaneDate: 2010-11-05 17:16:52
Subject: Re: ALTER OBJECT any_name SET SCHEMA name

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group