#100 BasicResourcePool contains endless loop

open
nobody
None
5
2014-12-15
2011-08-26
No

When a resource creation fails for whatever reason (see preferredTestQuery bug) then checkoutResource will be called endless. It is found in
BasicResourcePool.java line 514 of c3p0-0.9.1.2.
This will result in a StackOverflowError:

java.lang.StackOverflowError
at java.lang.Integer.parseInt(Integer.java:527)
at java.text.MessageFormat.makeFormat(MessageFormat.java:1418)
at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
at java.text.MessageFormat.<init>(MessageFormat.java:363)
at java.text.MessageFormat.format(MessageFormat.java:835)
at org.postgresql.util.GT.translate(GT.java:83)
at org.postgresql.util.GT.tr(GT.java:34)
at org.postgresql.util.ServerErrorMessage.toString(ServerErrorMessage.java:162)
at org.postgresql.util.PSQLException.<init>(PSQLException.java:32)
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:73)
at com.mchange.v2.c3p0.impl.DefaultConnectionTester.statusOnException(DefaultConnectionTester.java:143)
at com.mchange.v2.c3p0.AbstractConnectionTester.statusOnException(AbstractConnectionTester.java:82)
at com.mchange.v2.c3p0.impl.NewPooledConnection.handleThrowable(NewPooledConnection.java:437)
at com.mchange.v2.c3p0.impl.NewProxyStatement.executeQuery(NewProxyStatement.java:52)
at com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:73)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.testPooledConnection(C3P0PooledConnectionPool.java:374)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishResourceOnCheckout(C3P0PooledConnectionPool.java:237)
at com.mchange.v2.resourcepool.BasicResourcePool.attemptRefurbishResourceOnCheckout(BasicResourcePool.java:1579)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:479)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)

Discussion

  • Steve Waldman

    Steve Waldman - 2012-05-13

    So this kind of failure occurs if and only if resource creation is misconfigured somehow, that is if resource acquisition will just about always fail. It does not occur when resource creation fails for a temporary or idiosyncratic reason. If resource acquisition continually fails, something will have to break, although there might be better ways of breaking than a stack overflow. Still, since c3p0 can't in general diagnose the problem, the end result is going to be similar, the pool will try to acquire resources repeatedly, and if there are continual failures, it will eventually discontinue with an error.

     
  • Oswaldo Dantas

    Oswaldo Dantas - 2014-12-15

    Just for the benefit of others that maybe hit this old ticket, the latest version has a different behaviour (tested 0.9.5-pre10).

    For instance, if you have a wrong preferedTestQuery configured (like "select 1" while your database requires something with a from clause) you will see logs about it, and continuing to use the misconfigured connection will show other messages like "A PooledConnection that has already signalled a Connection error is still in use!", which is much better in helping to identify and fix the issue than a StackOverflowException.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks