Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id E3C1D9FB568 for ; Fri, 28 Sep 2007 23:15:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 54094-03 for ; Fri, 28 Sep 2007 23:15:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mirth.inuus.com (mirth.inuus.com [67.100.95.85]) by postgresql.org (Postfix) with ESMTP id 793BF9FB560 for ; Fri, 28 Sep 2007 23:15:48 -0300 (ADT) Received: from mirth.inuus.com (localhost.localdomain [127.0.0.1]) by mirth.inuus.com (8.14.1/8.14.1) with ESMTP id l8T2FRaM010357 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 28 Sep 2007 19:15:27 -0700 Received: (from lindner@localhost) by mirth.inuus.com (8.14.1/8.14.1/Submit) id l8T2FMVQ010356; Fri, 28 Sep 2007 19:15:22 -0700 X-Authentication-Warning: mirth.inuus.com: lindner set sender to lindner@inuus.com using -f Date: Fri, 28 Sep 2007 19:15:22 -0700 From: Paul Lindner To: Oliver Jowett Cc: Paul Lindner , pgsql-jdbc@postgresql.org Subject: Re: Prepared Statements vs. pgbouncer Message-ID: <20070929021522.GH3140@inuus.com> References: <20070929002513.GG3140@inuus.com> <46FDA4F2.8080507@opencloud.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="it/zdz3K1bH9Y8/E" Content-Disposition: inline In-Reply-To: <46FDA4F2.8080507@opencloud.com> User-Agent: Mutt/1.5.14 (2007-02-12) X-Virus-Scanned: ClamAV 0.91.2/4423/Fri Sep 28 16:56:49 2007 on mirth.inuus.com X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/132 X-Sequence-Number: 17554 --it/zdz3K1bH9Y8/E Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Sep 29, 2007 at 01:05:54PM +1200, Oliver Jowett wrote: > Paul Lindner wrote: > >the assumption of a singular > >client->server backend is causing this problem. >=20 > Well, yes, that's fairly fundamental to the client-server protocol. It=20 > sounds like pgbouncer is breaking the protocol. That's a given. Given the messages I've seen in the archives this affects pgpool as well. The advice offered was to downgrade jdbcv2. This, of course only works because the v2 code does not use server-side prepared statements. > You could perhaps do transparent statement/portal renaming in pgbouncer= =20 > but that seems to be only scratching the surface of the problem.=20 > Consider your case here: >=20 > > * Client A creates statement S_1, fetches results. > > When finished the statement is put in a cleanup queue. > > * time passes > > * pgbouncer notices that client A is idle and reassigns backend to=20 > > client B >=20 > Ok, now client A wakes up and wants to reuse S_1. What happens? The=20 > backend that knows about S_1 is currently in use by B. We're currently using Transaction pooling with pgbouncer. With prepareThreshhold set to 0, the only cases where server-side statements are used are with cursors. These occur inside transactions on our end. It seems that the driver should immediately deallocate the server-side prepared statements it creates for cursors when it finishs fetching data for that cursor. This would be much better than waiting for the garbage collector to issue the deallocation. > Changing the JDBC driver to handle a "server" that doesn't follow the=20 > documented server protocol seems a bit backwards. I think you're going=20 > to have to teach pgbouncer a whole lot more about statements and portals= =20 > to get this one working. Well.. I only use pgBouncer to solve my particular issues. Digging a little deeper I see that Postgres 8.3 will have DEALLOCATE ALL and DISCARD ALL commands that can be used in pgbouncers health check. Still, it would be nice if the end-user could have some control over how the JDBC driver uses prepared statements other than prepareThreshhold Thanks! --=20 Paul Lindner ||||| | | | | | | | | | lindner@inuus.com --it/zdz3K1bH9Y8/E Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFG/bU5+FkoUnP1gFQRApfjAJ9eZpETvIeaCI0dbqQw4eNbN7O9gQCgk03C sUYQulIa++gA9kG+aKfgLQU= =y0gw -----END PGP SIGNATURE----- --it/zdz3K1bH9Y8/E--