pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Stephen Frost <sfrost@snowman.net>
Cc: Radosław Smogura <rsmogura@softperience.eu>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: David Fetter <david@fetter.org>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: PG Hackers <pgsql-hackers@postgresql.org>
Cc: PostgreSQL JDBC List <pgsql-jdbc@postgresql.org>
Cc: robertmhaas@gmail.com
Subject: Re: [JDBC] Support for JDBC setQueryTimeout, et al.
Date: Sat, 16 Oct 2010 10:51:22 +0800
Message-ID: <4CB9132A.6040009@postnewspapers.com.au> (raw)
In-Reply-To: <20260.1287153534@sss.pgh.pa.us>
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>
	<AANLkTi=m7tzv7RzCmqD6ARWm_QWbg90Jmd0uTkosiZo4@mail.gmail.com>
	<528f31015d6bf68650646b9b4ba71a10@smogura-softworks.eu>
	<AANLkTinFMPHaa1SH-uf7fqBTkVcMZYRpxqjaaYUKHEHA@mail.gmail.com>
	<c17d0cbfea679088a106a9c9b573196c@smogura-softworks.eu>
	<20101015142126.GQ26232@tamriel.snowman.net>
	<20260.1287153534@sss.pgh.pa.us>

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/



view thread (45+ messages)  latest in thread

Message-ID: <4CB9132A.6040009@postnewspapers.com.au>
Permalink:  ../4CB9132A.6040009@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4CB9132A.6040009@postnewspapers.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: craig@postnewspapers.com.au, tgl@sss.pgh.pa.us, sfrost@snowman.net, rsmogura@softperience.eu, magnus@hagander.net, david@fetter.org, Kevin.Grittner@wicourts.gov, pgsql-hackers@postgresql.org, robertmhaas@gmail.com
  Subject: Re: [JDBC] Support for JDBC setQueryTimeout, et al.
  In-Reply-To: <4CB9132A.6040009@postnewspapers.com.au>
  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> <AANLkTi=m7tzv7RzCmqD6ARWm_QWbg90Jmd0uTkosiZo4@mail.gmail.com> <528f31015d6bf68650646b9b4ba71a10@smogura-softworks.eu> <AANLkTinFMPHaa1SH-uf7fqBTkVcMZYRpxqjaaYUKHEHA@mail.gmail.com> <c17d0cbfea679088a106a9c9b573196c@smogura-softworks.eu> <20101015142126.GQ26232@tamriel.snowman.net> <20260.1287153534@sss.pgh.pa.us> <4CB9132A.6040009@postnewspapers.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox