Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id CC379632CF2 for ; Sun, 14 Feb 2010 16:41:20 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 97120-10 for ; Sun, 14 Feb 2010 20:41:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-08.primus.ca (smtp-noauth7.primus.ca [216.254.180.38]) by mail.postgresql.org (Postfix) with ESMTP id 25A5D632951 for ; Sun, 14 Feb 2010 16:41:09 -0400 (AST) Received: from [206.191.44.11] (helo=bambi.pccyber.com) by mail-08.primus.ca with esmtp (Exim 4.69) (envelope-from ) id 1NglH7-0008OP-15; Sun, 14 Feb 2010 15:41:05 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by bambi.pccyber.com (Postfix) with ESMTP id D9C591B49BC; Sun, 14 Feb 2010 15:41:03 -0500 (EST) X-Virus-Scanned: amavisd-new at pccyber.com Received: from bambi.pccyber.com ([127.0.0.1]) by localhost (bambi.pccyber.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4gG3Qcolwrxm; Sun, 14 Feb 2010 15:41:03 -0500 (EST) Received: from [173.35.103.0] (CPE0050fca9b0e1-CM0018c0d3a5ba.cpe.net.cable.rogers.com [173.35.103.0]) (Authenticated sender: mark@pccyber.com) by bambi.pccyber.com (Postfix) with ESMTPA id 08C9D1B49BB; Sun, 14 Feb 2010 15:41:02 -0500 (EST) Message-ID: <4B785FDE.8040308@mark.mielke.cc> Date: Sun, 14 Feb 2010 15:41:02 -0500 From: Mark Mielke User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc12 Thunderbird/3.0.1 MIME-Version: 1.0 To: Florian Weimer CC: Tom Lane , Andres Freund , Greg Stark , Robert Haas , pgsql-hackers@postgresql.org Subject: Re: Re: Faster CREATE DATABASE by delaying fsync References: <4427a97a0912101235x3ade510blcc00d5ce9883c6b6@mail.gmail.com> <407d949e1002140731j85a4f97nc053ec1b0f3cc458@mail.gmail.com> <22295.1266167499@sss.pgh.pa.us> <201002141827.04993.andres@anarazel.de> <22649.1266169035@sss.pgh.pa.us> <87wryfpnuv.fsf@mid.deneb.enyo.de> In-Reply-To: <87wryfpnuv.fsf@mid.deneb.enyo.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.373 tagged_above=-10 required=5 tests=AWL=0.226, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/1161 X-Sequence-Number: 157504 On 02/14/2010 03:24 PM, Florian Weimer wrote: > * Tom Lane: > >>> Which options would that be? I am not aware that there any for any of the >>> recent linux filesystems. >>> >> Shouldn't journaling of metadata be sufficient? >> > You also need to enforce ordering between the directory update and the > file update. The file metadata is flushed with fsync(), but the > directory isn't. On some systems, all directory operations are > synchronous, but not on Linux. > dirsync All directory updates within the filesystem should be done syn- chronously. This affects the following system calls: creat, link, unlink, symlink, mkdir, rmdir, mknod and rename. The widely reported problems, though, did not tend to be a problem with directory changes written too late - but directory changes being written too early. That is, the directory change is written to disk, but the file content is not. This is likely because of the "ordered journal" mode widely used in ext3/ext4 where metadata changes are journalled, but file pages are not journalled. Therefore, it is important for some operations, that the file pages are pushed to disk using fsync(file), before the metadata changes are journalled. In theory there is some open hole where directory updates need to be synchronized with file updates, as POSIX doesn't enforce this ordering, and we can't trust that all file systems implicitly order things correctly, but in practice, I don't see this sort of problem happening. If you are concerned, enable dirsync. Cheers, mark -- Mark Mielke