Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eA4OR-0005BJ-55 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2017 01:34:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eA4OQ-0000Jh-1O for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2017 01:34:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eA4ON-0000IB-GR for pgsql-hackers@postgresql.org; Thu, 02 Nov 2017 01:33:59 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eA4OJ-0001Br-Vg for pgsql-hackers@postgresql.org; Thu, 02 Nov 2017 01:33:58 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 8F6A1209D5; Wed, 1 Nov 2017 21:33:53 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Wed, 01 Nov 2017 21:33:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=W528jg bGA/WLo9954fgv3taShn6ObSnv1sYx8xbcvT4=; b=EELYKXF9moszszAJCcR+9B x/4TQmuO/3JUsrB1onaXRy4PJTLwh7vS9t0lkFHE0cHL12uqvGl85EpZKcQJYVDv ppORH/uhIU5hf4HOlcRsGX30X+BSP0WvCmAx7hjOonEOMeK+c/M9MD8wuIK3BzBJ /pl8vYxFtdNlGpujMwN2Tl0On4evb7CrQ9CocvEIrnj8jLKzya+9FiVaYKZFnuRL 8GMr9fw6SSLv/M08QHynypy0q5Y+4xEogvQ92cnl5EvhPrnek9wFf4QBpvRHsxMM GF3nnCPQnK1iyQ0JRldMPeJoEZXHJxBKwTyx+7mcEW3f6bZGfSuw60O3G4b91W/Q == X-ME-Sender: Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 37916241D9; Wed, 1 Nov 2017 21:33:53 -0400 (EDT) Subject: Re: Statement-level rollback To: MauMau , Simon Riggs References: <0A3221C70F24FB45833433255569204D1F6A9286@G01JPEXMBYT05> Cc: "Tsunakawa, Takayuki" , pgsql-hackers@postgresql.org From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Wed, 1 Nov 2017 21:33:52 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 10/31/17 13:47, MauMau wrote: > I'm very sorry I couldn't reply to your kind offer. I rebased the > patch and will add it to CF 2017/11. I hope I will complete the patch > in this CF. I've been thinking about this a little bit. Many are worried about repeating the mistakes of the autocommit feature, so it's worth comparing that. The problem with the autocommit setting, or at least the one I remember, is that code is currently written expecting that connect exec SQL statement disconnect will succeed in executing and committing the SQL statement, unless an error is reported. If you turned the autocommit setting off, then this code would effectively silently do nothing, and that is obviously quite bad. So the autocommit setting would break a large proportion of all code out there, and was thus not really usable, and hence it was removed. The proposed statement-level rollback feature works in a slightly different context. It does not change when or how a transaction or transaction block begins and ends. It only changes what happens inside explicit transaction blocks. Considering code like START TRANSACTION; SQL1; SQL2; SQL3; COMMIT; currently an error would cause all subsequent commands to fail. Under statement-level rollback, a failed command would effectively be ignored and the transaction would continue until COMMIT. Therefore, a successful transaction block would always work the same way under either setting. The difference is how error recovery works. So this will necessarily be tied to how the client code or other surrounding code is structured or what the driver or framework is doing in the background to manage transactions. It would also be bad if client code was not prepared for this new behavior, reported the transaction as complete while some commands in the middle were omitted. Drivers can already achieve this behavior and do do that by issuing savepoint commands internally. The point raised in this thread was that that creates too much network overhead, so a backend-based solution would be preferable. We haven't seen any numbers or other evidence to quantify that claim, so maybe it's worth looking into that some more. In principle, a backend-based solution that drivers just have to opt into would save a lot of duplication. But the drivers that care or require it according to their standards presumably already implement this behavior in some other way, so it comes back to whether there is a performance or other efficiency gain here. Another argument was that other SQL implementations have this behavior. This appears to be the case. But as far as I can tell, it is also tied to their particular interfaces and the structure and flow control they provide. So a client-side solution like psql already provides or something in the various drivers would work just fine here. So my summary for the moment is that a GUC or similar run-time setting might be fine, with appropriate explanation and warnings. But it's not clear whether it's worth it given the existing alternatives. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers