pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marti Raudsepp <marti@juffo.org>
To: Greg Smith <greg@2ndquadrant.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: Defaulting wal_sync_method to fdatasync on Linux for 9.1?
Date: Sat, 6 Nov 2010 01:32:26 +0200
Message-ID: <AANLkTimhNzer1TOEnL55P-Un9TPp8fAeyOzX09259RxN@mail.gmail.com> (raw)
In-Reply-To: <4CD47FCD.6010106@2ndquadrant.com>
References: <AANLkTi=n3zxiLNFhbpiN=JPQPwB=BhXf9iepw1KOEs8U@mail.gmail.com>
	<4CCDCAA3.4050805@2ndquadrant.com>
	<201011010010.28724.andres@anarazel.de>
	<4CD472CC.80006@2ndquadrant.com>
	<AANLkTinEAmKDz7x356bgX=-6x7zpjK3bB0hYAmKvYHB9@mail.gmail.com>
	<4CD47FCD.6010106@2ndquadrant.com>

On Sat, Nov 6, 2010 at 00:06, Greg Smith <greg@2ndquadrant.com> wrote:
>  Please refrain from making changes to popular documents like the
> tuning guide on the wiki based on speculation about what's happening.

I will grant you that the details were wrong, but I stand by the conclusion.

I can state for a fact that PostgreSQL's default wal_sync_method
varies depending on the <fcntl.h> header.
I have two PostgreSQL 9.0.1 builds, one with older
/usr/include/bits/fcntl.h and one with newer.

When I run "show wal_sync_method;" on one instance, I get fdatasync.
On the other one I get open_datasync.

So let's get down to code.

Older fcntl.h has:
#define O_SYNC		 010000
# define O_DSYNC	O_SYNC	/* Synchronize data.  */

Newer has:
#define O_SYNC	       04010000
# define O_DSYNC	010000	/* Synchronize data.  */

So you can see that in the older header, O_DSYNC and O_SYNC are equal.

src/include/access/xlogdefs.h does:

#if defined(O_SYNC)
#define OPEN_SYNC_FLAG      O_SYNC
...
#if defined(OPEN_SYNC_FLAG)
/* O_DSYNC is distinct? */
#if O_DSYNC != OPEN_SYNC_FLAG
#define OPEN_DATASYNC_FLAG      O_DSYNC

^ it's comparing O_DSYNC != O_SYNC

#if defined(OPEN_DATASYNC_FLAG)
#define DEFAULT_SYNC_METHOD     SYNC_METHOD_OPEN_DSYNC
#elif defined(HAVE_FDATASYNC)
#define DEFAULT_SYNC_METHOD     SYNC_METHOD_FDATASYNC

^ depending on whether O_DSYNC and O_SYNC were equal, the default
wal_sync_method will change.

Regards,
Marti



view thread (46+ messages)  latest in thread

Message-ID: <AANLkTimhNzer1TOEnL55P-Un9TPp8fAeyOzX09259RxN@mail.gmail.com>
Permalink:  ../AANLkTimhNzer1TOEnL55P-Un9TPp8fAeyOzX09259RxN@mail.gmail.com/
Also on:    postgresql.org/message-id/AANLkTimhNzer1TOEnL55P-Un9TPp8fAeyOzX09259RxN@mail.gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: marti@juffo.org, greg@2ndquadrant.com, andres@anarazel.de
  Subject: Re: Defaulting wal_sync_method to fdatasync on Linux for 9.1?
  In-Reply-To: <AANLkTimhNzer1TOEnL55P-Un9TPp8fAeyOzX09259RxN@mail.gmail.com>
  References: <AANLkTi=n3zxiLNFhbpiN=JPQPwB=BhXf9iepw1KOEs8U@mail.gmail.com> <4CCDCAA3.4050805@2ndquadrant.com> <201011010010.28724.andres@anarazel.de> <4CD472CC.80006@2ndquadrant.com> <AANLkTinEAmKDz7x356bgX=-6x7zpjK3bB0hYAmKvYHB9@mail.gmail.com> <4CD47FCD.6010106@2ndquadrant.com> <AANLkTimhNzer1TOEnL55P-Un9TPp8fAeyOzX09259RxN@mail.gmail.com>

* 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