Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 051711337B67 for ; Fri, 15 Oct 2010 23:51:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 21414-07; Sat, 16 Oct 2010 02:51:40 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 5B83D1336DB6; Fri, 15 Oct 2010 23:51:37 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 4D00FAEF0C; Sat, 16 Oct 2010 10:51:35 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id NeCXLKgAXZQs; Sat, 16 Oct 2010 10:51:29 +0800 (WST) Received: from [10.1.1.3] (203-59-65-233.dyn.iinet.net.au [203.59.65.233]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 15E8DAEF0B; Sat, 16 Oct 2010 10:51:27 +0800 (WST) Message-ID: <4CB9132A.6040009@postnewspapers.com.au> Date: Sat, 16 Oct 2010 10:51:22 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.12) Gecko/20100914 Thunderbird/3.0.8 MIME-Version: 1.0 To: Tom Lane CC: Stephen Frost , =?UTF-8?B?UmFkb3PFgmF3IFNtb2d1cmE=?= , Magnus Hagander , David Fetter , Kevin Grittner , PG Hackers , PostgreSQL JDBC List , robertmhaas@gmail.com Subject: Re: [JDBC] Support for JDBC setQueryTimeout, et al. References: <20101011064615.GJ29408@fetter.org> <4CB2CADC020000250003676B@gw.wicourts.gov> <88dcb3988805ede17af4a460ad251534@smogura-softworks.eu> <20101012141439.GA29627@fetter.org> <4CB43A4C0200002500036826@gw.wicourts.gov> <20101012155531.GB29627@fetter.org> <528f31015d6bf68650646b9b4ba71a10@smogura-softworks.eu> <20101015142126.GQ26232@tamriel.snowman.net> <20260.1287153534@sss.pgh.pa.us> In-Reply-To: <20260.1287153534@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201010/1066 X-Sequence-Number: 172106 On 15/10/2010 10:38 PM, Tom Lane wrote: > Yeah, actually what you need is DISCARD ALL when reassigning a > connection to another client. Anything less than that assumes the > clients are cooperating closely, ie they *want* the same prepared > statements etc. For what it's worth, this is quite common in the world of web apps. Java EE application servers, in particular, tend to offer per-application connection pools that can significantly benefit from this sort of thing. I don't know how much that sort of co-operating group of apps is likely to use external pooling via PgPool and friends, though. Most such apps have an *internal* connection pool, whether managed by an appserver, web server, or by the app code its self. The JDBC driver's org.postgresql.ds.PGPoolingDataSource is rather unclear about how it behaves in terms of resetting GUCs, resetting roles, clearing prepared statements etc between connection uses, so it's not clear what category it falls into. The docs suggest it's a bit of a toy implementation that's not intended for real-world production use, though. OTOH, it's not clear how connection pools like DBCP should know how or when to do this when returning a PostgreSQL connection to the pool, so it may well be an issue for "serious" non-Pg-specific pools too. The JDBC spec doesn't seem to offer a generic "reset this connection to defaults" method for use when pooling a connection. > But even if you make that assumption, a pooler that > isn't even capable of sending an ABORT between clients doesn't seem > usable to me. For example, if a client loses its network connection > mid-transaction, that failure will cascade to other clients if you > don't have any ability to reset the database session before handing > it to another client. You can never really assume that the connection you get from a pool (or have directly made) is working and usable, though. You always have to be prepared to handle failures because someone trips over an Ethernet cable, etc, so you can get a fresh connection and re-issue your transaction. Nonetheless, I tend to agree that pools should make some effort to handle failures in one connection that indicate likely failure in all other connections, re-testing all the connections before handing them out to clients. -- Craig Ringer Tech-related writing at http://soapyfrogs.blogspot.com/