Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQfhd-0001eh-CS for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Apr 2013 15:15:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQfhc-0002kA-4w for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Apr 2013 15:15:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQfhU-0002dw-Tv for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 15:15:41 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQfhP-0002TK-BT for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 15:15:40 +0000 Received: from intern.anarazel.de (p5DDC5889.dip.t-dialin.net [93.220.88.137]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id C7F0E4F0001; Fri, 12 Apr 2013 17:15:33 +0200 (CEST) Date: Fri, 12 Apr 2013 17:15:32 +0200 From: Andres Freund To: Tom Lane Cc: tarvip@gmail.com, pgsql-bugs@postgresql.org Subject: Re: BUG #8059: sequence crash recovery is not working properly Message-ID: <20130412151532.GH5766@alap2.anarazel.de> References: <20130412140416.GF5766@alap2.anarazel.de> <17168.1365778072@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17168.1365778072@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 2013-04-12 10:47:52 -0400, Tom Lane wrote: > Andres Freund writes: > > Thats caused by the fact that you didn't do anything that forces a WAL > > flush since you didn't do any inserts or such. If you would do any > > DML in the nextval() calling transaction this shouldn't happen (unless > > you use synchronous_commit=off). > > Now, there's a legitimate argument to be made that returning the > > sequence value to the user kinda persists it. On the other hand, at > > least in the first example you haven't even committed the transaction so > > there's nothing that could flush the transaction unless we we would > > *always* flush nextval() immediately if needs to get new values which > > doesn't seem reasonable. > > I believe we've gone around on this before and decided to leave it > as-is. The thinking is that any realistic use-case would involve > storing the nextval result into some table somewhere, so that additional > WAL and a commit record would be generated. Hm. I couldn't find anything about that discussions after searching some minutes. I am not really sure if I can follow that argument, its not uncommon to use the database sequences to prepare data thats then inserted lateron. In a separate transaction and possibly even in a separate connection. In the latter case you wouldn't even notice the database has restarted. I don't think flushing the WAL immediately in nextval_internal is a realistic thing to do, but making it generate an xid if its doing WAL logging sounds like a compromise with acceptable overhead. In the normal usage where you use to directly insert it won't have any additional overhead since the xid will have to be generated anyway and if you use it in a separate transaction/connection you want the flush at commit. Sure, if somebody loops around SELECT nextval(...); without using a transaction that will increase the overhead, but that doesn't sound like a terribly good idea anyway. On a tangent: I'd still really like to have nextval(..., how_many_values) or such... 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