Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 36A1E9F9A4E for ; Sat, 29 Sep 2007 11:31:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 44320-06 for ; Sat, 29 Sep 2007 11:31:42 -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 F2E8E9F9AF2 for ; Sat, 29 Sep 2007 11:31: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 l8TEV70t018499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 29 Sep 2007 07:31:07 -0700 Received: (from lindner@localhost) by mirth.inuus.com (8.14.1/8.14.1/Submit) id l8TEV2xt018498; Sat, 29 Sep 2007 07:31:02 -0700 X-Authentication-Warning: mirth.inuus.com: lindner set sender to lindner@inuus.com using -f Date: Sat, 29 Sep 2007 07:31:02 -0700 From: Paul Lindner To: Oliver Jowett Cc: Paul Lindner , Tom Lane , pgsql-jdbc@postgresql.org, markokr@gmail.com Subject: Re: Prepared Statements vs. pgbouncer Message-ID: <20070929143102.GJ3140@inuus.com> References: <20070929002513.GG3140@inuus.com> <46FDA4F2.8080507@opencloud.com> <20070929021522.GH3140@inuus.com> <24584.1191033096@sss.pgh.pa.us> <20070929072159.GI3140@inuus.com> <46FE1035.8050801@opencloud.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="n8884J15jRwcBTvu" Content-Disposition: inline In-Reply-To: <46FE1035.8050801@opencloud.com> User-Agent: Mutt/1.5.14 (2007-02-12) X-Virus-Scanned: ClamAV 0.91.2/4426/Fri Sep 28 22:28:01 2007 on mirth.inuus.com X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/142 X-Sequence-Number: 17564 --n8884J15jRwcBTvu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Sep 29, 2007 at 08:43:33PM +1200, Oliver Jowett wrote: > Paul Lindner wrote: >=20 > > * 100s of application servers using Torque and DBCP > > * Dozens of databases. > > * All app servers can connect to all databases. > > * Each application server may need many connections to an individual > > database. > > * App code as written will spawn multiple concurrent SELECTs to > > a single database to speed up queries on partitioned tables. >=20 > I'm assuming there is some reason why you can't run the same apps on=20 > fewer appservers and share the pools. The basic problem here is that you= =20 > can't get a good global view of which connections are idle because you=20 > have a lot of separate appservers each doing their own thing. Partially, yes. DBCP and Torque are supposed to take care of this, however the idle connection reaper is buggy/doesn't work correctly for us. This results in app servers quickly going to their max pool size. What other client-side connection pools are people using? Is Sequoia an option? I have not tried it as of yet. > > 3. Use pgbouncer to allow 6k connections while actually > > lowering the number of DB backends, plus giving us some very cool > > maintenance features like redirecting connections to other hosts > > and more. > > > >So we we're trying to implement #3. >=20 > That is a reasonable approach to take, that's essentially giving you a=20 > global connection pool. However.. >=20 > >The only thing holding us back from deploying the pgbouncer solution > >is this issue with the server-side prepared statements. =20 >=20 > This is a really an issue with pgbouncer's incomplete implementation of= =20 > the protocol. Okay, can we get the JDBC people talking with the pgbouncer people (and the pgpool, pgcluster people too...) I've Cc'd Marko and hope to get him into this conversation, especially since the suggested fix of using DEALLOCATE ALL, DISCARD ALL will probably not work with the JDBC driver as is. Note that each of those products has the exact same issues: http://pgfoundry.org/pipermail/pgbouncer-general/2007-June/000004.html http://archives.postgresql.org/pgsql-jdbc/2007-02/msg00132.php http://pgfoundry.org/pipermail/pgcluster-general/2006-October/001070.html http://pgfoundry.org/pipermail/pgpool-general/2006-January/000275.html We really need to have some way of maintaining server/client coherency... Also, it would be in all of our best interests to solve this problem. As it stands we could never use a load balancer of any sort to maintain a highly reliable pool of read-only replicas. > If you were going to change the driver the best place to do it is in the= =20 > V3 protocol code itself -- tell it not to use named statements at all.=20 > The higher layers in the driver are working to a different API that=20 > doesn't know anything about named statements at all, it just provides=20 > hints about whether a query is likely to be re-used or not. So trying to= =20 > repair particular instances of that so they don't used named statements= =20 > is going to be fairly error-prone. >=20 > I don't see that sort of change going into the official driver though ..= =20 > as Tom says, why would we deliberately cripple use of the protocol=20 > because a 3rd party piece of software can't handle the full protocol? So= =20 > I think you are going to be stuck with either deploying a customized=20 > JDBC driver for your particular environment, or fixing pgbouncer so that= =20 > it properly implements the protocol. I never said I wanted the driver crippled. I'm just looking for a way to make this scenario work for me. You already provide prepareThreshold=3DX for people that don't want automatic server-side prepared statements. =20 How about I code up a patch that adds a new parameter preparePrefix=3DXXX to DSN, and add a global utility method to set the same? Would you accept such a patch? --=20 Paul Lindner ||||| | | | | | | | | | lindner@inuus.com --n8884J15jRwcBTvu Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFG/mGl+FkoUnP1gFQRAnU4AJ9rjy6sxCN5j8VlSUsOeYtumTZ/bwCggruA vFOgiG1a2QPKXE0v6MAP8lQ= =fICV -----END PGP SIGNATURE----- --n8884J15jRwcBTvu--