Re: Directory fsync and other fun - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Directory fsync and other fun
Date
Msg-id 407d949e1002232309m3518538fta5ebc5ef18c1ea7e@mail.gmail.com
Whole thread Raw
In response to Re: Directory fsync and other fun  (Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>)
List pgsql-hackers
On Wed, Feb 24, 2010 at 2:51 AM, Takahiro Itagaki
<itagaki.takahiro@oss.ntt.co.jp> wrote:
> Also, I heard ext4 has a "feature" in that rename() might truncate the
> renamed file to zero bytes on crash. The user data in the file might be
> lost if the machine crashes just after rename().

In our case I think this is the one thing that cannot happen. This
happens when you write out the new file and rename it over the old
file without every fsyncing the new file. If the rename succeeds but
all the writes get lost you end up with neither the new nor old file.

The ext4 guys want you do to do an fsync of the new file before doing
the rename. This is terrible for most of the applications that were
doing this -- the latency hit for interactive apps that didn't really
need an fsync is awful -- but in our case we were already doing fsyncs
in every case where we do renames.




-- 
greg


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Issues for named/mixed function notation patch
Next
From: Simon Riggs
Date:
Subject: Re: [COMMITTERS] pgsql: Move documentation of all recovery.conf option to a new chapter.