Thread: Closing one connection closes all connections?
Greetings, I'm getting interesting behavior from connection pooling when I use PostgreSQL + pg73jdbc2ee.jar: specifically, closing one connection from the pool seems to close all connections: (This example using Tomcat.) Test 0. Comparing two connection objects from PostgreSQL driver: org.apache.commons.dbcp.PoolableConnection@895cb9, org.apache.commons.dbcp.PoolableConnection@26a4a2: Equal? false con.isClosed(): false con2.isClosed(): false Closing con with con.close() con.isClosed(): true con2.isClosed(): true End of test 0. The connection in question is being returned from a datasource.getConnection() call. As a separate issue, sometimes this same call will in fact return the same instance of a connection in two subsequent calls. I haven't gone and looked at the spec yet, but this seems to me to be incorrect behavior. (As does the behavior illustrated above.) Where is the canonical source for the JDBC driver, anyway? I'd love to look through the source for it and see if I can track down this issue. Are people using connection pooling with PostgreSQL successfully in production code? Do I have the wrong version of the JAR? I tried to find more on this in the list archives, but wasn't able to so far. Sorry if this is a FAQ and I'm overlooking something. Cheers, -Ian
See my comments below On Tue, 2003-03-04 at 05:15, Ian McFarland wrote: > Greetings, > > I'm getting interesting behavior from connection pooling when I use > PostgreSQL + pg73jdbc2ee.jar: specifically, closing one connection from > the pool seems to close all connections: (This example using Tomcat.) > > > Test 0. > Comparing two connection objects from PostgreSQL driver: > org.apache.commons.dbcp.PoolableConnection@895cb9, > org.apache.commons.dbcp.PoolableConnection@26a4a2: Equal? false > con.isClosed(): false > con2.isClosed(): false > Closing con with con.close() > con.isClosed(): true > con2.isClosed(): true > End of test 0. > > The connection in question is being returned from a > datasource.getConnection() call. As a separate issue, sometimes this > same call will in fact return the same instance of a connection in two > subsequent calls. I haven't gone and looked at the spec yet, but this > seems to me to be incorrect behavior. (As does the behavior illustrated > above.) yes this is not correct behaviour > > Where is the canonical source for the JDBC driver, anyway? I'd love to > look through the source for it and see if I can track down this issue. check http://developer.postgresql.org/TODO/docs/cvs.html to see how to download the source get all of it and go through the exercise of ./configure --with-java to set everything up. You don't need to but this will make it easier. You can just specify the -D options for ant and build just the java source > > Are people using connection pooling with PostgreSQL successfully in > production code? Do I have the wrong version of the JAR? I tried to > find more on this in the list archives, but wasn't able to so far. > Sorry if this is a FAQ and I'm overlooking something. I don't use it, I create my own pool Dave > > Cheers, > -Ian > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org -- Dave Cramer <Dave@micro-automation.net>
First of all, the connection class you show below indicates that you are using Tomcat connection pooling, not PostgreSQL connection pooling. So this issue should really be raised with the Tomcat developers. (Note the org.apache... not org.postgresql...) Second of all, it is common for two clients in the same transaction to get the same physical conenction, but usually you get two different wrapper objects (the org.apache thingy) that wrap the same conenction, and can be closed separately. So the behavior you're seeing does strike me as a little odd, but it's hard to know without looking into the exact circumstances (TX timing and all). Aaron On 5 Mar 2003, Dave Cramer wrote: > See my comments below > > On Tue, 2003-03-04 at 05:15, Ian McFarland wrote: > > Greetings, > > > > I'm getting interesting behavior from connection pooling when I use > > PostgreSQL + pg73jdbc2ee.jar: specifically, closing one connection from > > the pool seems to close all connections: (This example using Tomcat.) > > > > > > Test 0. > > Comparing two connection objects from PostgreSQL driver: > > org.apache.commons.dbcp.PoolableConnection@895cb9, > > org.apache.commons.dbcp.PoolableConnection@26a4a2: Equal? false > > con.isClosed(): false > > con2.isClosed(): false > > Closing con with con.close() > > con.isClosed(): true > > con2.isClosed(): true > > End of test 0. > > > > The connection in question is being returned from a > > datasource.getConnection() call. As a separate issue, sometimes this > > same call will in fact return the same instance of a connection in two > > subsequent calls. I haven't gone and looked at the spec yet, but this > > seems to me to be incorrect behavior. (As does the behavior illustrated > > above.) > yes this is not correct behaviour > > > > Where is the canonical source for the JDBC driver, anyway? I'd love to > > look through the source for it and see if I can track down this issue. > check http://developer.postgresql.org/TODO/docs/cvs.html to see how to > download the source > > get all of it and go through the exercise of ./configure --with-java to > set everything up. You don't need to but this will make it easier. You > can just specify the -D options for ant and build just the java source > > > > > > Are people using connection pooling with PostgreSQL successfully in > > production code? Do I have the wrong version of the JAR? I tried to > > find more on this in the list archives, but wasn't able to so far. > > Sorry if this is a FAQ and I'm overlooking something. > I don't use it, I create my own pool > > Dave > > > > Cheers, > > -Ian > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 6: Have you searched our list archives? > > > > http://archives.postgresql.org >