Re: fsync, ext2 on Linux

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: fsync, ext2 on Linux
Date: 2004-10-31 18:02:09
Message-ID: Pine.OSF.4.61.0410311936360.256140@kosh.hut.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 1 Nov 2004, Oliver Jowett wrote:

> Heikki Linnakangas wrote:
>> The Linux fsync man page says:
>>
>> "It does not necessarily ensure that the entry in the directory containing
>> the file has also reached disk. For that an explicit fsync on the file
>> descriptor of the directory is also needed."
>>
>> AFAIK, we don't care about it at the moment. The actual behaviour depends
>> on the filesystem, reiserfs and other journaling filesystems probably don't
>> need the explicit fsync on the parent directory, but at least ext2 does.
>>
>> I've experimented with a user-mode-linux installation, crashing it at
>> specific points. It seems that on ext2, it's possible to get the database
>> in non-consistent state.
>
> Have you experimented with mounting the filesystem with the dirsync option
> ('-o dirsync') or marking the log directory as synchronous with 'chattr +D'?
> (no, it's not a real fix, just another data point..)

Quick experiment shows that they seem to fix it as expected.

"chattr +D" might not be such a bad idea. A warning would be nice if you
start the postmaster on a filesystem that requires it. Few admins would
remember/know about it otherwise.

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2004-10-31 18:19:35 Re: fsync, ext2 on Linux
Previous Message Tom Lane 2004-10-31 17:49:59 Re: Version defines