Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wt3Is-0003Cu-Ai for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Jun 2014 23:12:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wt3Ir-0002FH-7N for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Jun 2014 23:12:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Wt3Iq-0002FA-6t for pgsql-bugs@postgresql.org; Fri, 06 Jun 2014 23:12:04 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wt3Ii-00074p-KL for pgsql-bugs@postgresql.org; Fri, 06 Jun 2014 23:12:03 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 85CBB4E8007; Sat, 7 Jun 2014 01:11:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-6.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC41C2.dip0.t-ipconnect.de [93.220.65.194]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id A83F74E8007; Sat, 7 Jun 2014 01:11:49 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 1DF8B100561; Sat, 7 Jun 2014 01:11:49 +0200 (CEST) Date: Sat, 7 Jun 2014 01:11:49 +0200 From: Andres Freund To: Tom Lane Cc: Alvaro Herrera , Keith Fiske , Heikki Linnakangas , levertond@googlemail.com, "pgsql-bugs@postgresql.org" Subject: Re: BUG #10533: 9.4 beta1 assertion failure in autovacuum process Message-ID: <20140606231149.GA24880@awork2.anarazel.de> References: <20140605180121.3061.28250@wrigleys.postgresql.org> <5390BA0F.2030103@vmware.com> <20140605213436.GA17217@awork2.anarazel.de> <20140606205557.GX5146@eldon.alvh.no-ip.org> <20140606205801.GB23201@awork2.anarazel.de> <13635.1402092233@sss.pgh.pa.us> <20140606220537.GC23201@awork2.anarazel.de> <14003.1402093305@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14003.1402093305@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2014-06-06 18:21:45 -0400, Tom Lane wrote: > Also, there are a bunch of fsync_fname() calls inside critical sections in > replication/slot.c. Seems at best pretty damn risky; what's more, the > critical sections cover only the fsyncs and not anything else, which is > flat out broken. If it was okay to fail just before calling the fsync, > why is it critical to not fail inside it? Somebody was not thinking > clearly there. No, it actually makes sense. If: * the open, write or fsync to the temp file fails: no permanent state has changed. We can gracefully error out. * rename(tmpfile, realname) fails: we know (by posix) that the file hasn't been renamed. The old state is still valid. * if the fsync() to the new file fails (damn unlikely) we don't know which state is valid. So if we'd crash in that moment we might loose our reservation on resources (e.g. catalog xmin). And might start to decode with the wrong catalog state. Bad. On startup we'll try to fsync the slot files again, so we won't startup until that's clear. Why is it that risky? We fdatasync() files while inside a critical section all the time. And we've done the space allocation (the fsync on the old filename) and the rename() outside the critical section. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs