-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Problem C3P0 / Oracle / Connection is invalid
PostPosted: Tue May 17, 2005 9:20 am 
Newbie

Joined: Tue May 17, 2005 8:55 am
Posts: 11
Hi,

i'm using C3P0 as connection-pool for a Tomcat/Struts/Oracle App

The connection-pool config:

Code:
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@15412e75
[ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@769aba32
[ acquireIncrement -> 5,
autoCommitOnClose -> false,
connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester,
factoryClassLocation -> null,
forceIgnoreUnresolvedTransactions -> false,
idleConnectionTestPeriod -> 10,
initialPoolSize -> 25,
maxIdleTime -> 0,
maxPoolSize -> 100,
maxStatements -> 0,
minPoolSize -> 10,
nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@6a510e39
[ description -> null,
driverClass -> oracle.jdbc.driver.OracleDriver,
factoryClassLocation -> null,
jdbcUrl -> jdbc:oracle:thin:@xxxx:1521:xxx,
properties -> {user=xxxx, password=xxx} ] ,
propertyCycle -> 300,
testConnectionOnCheckout -> true ] ,
factoryClassLocation -> null,
numHelperThreads -> 10 ]


The Oracle/JDBC config:

Code:
Oracle: Database Product Version is  Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Oracle Data Mining options
JDBC: JDBC Driver Version is ..... 10.1.0.2.0


When i'm doing some load-test, after a while i'm getting those exceptions:

Quote:
java.sql.SQLException: Connection is invalid
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.refurbishResource(C3P0PooledConnectionPool.java:141)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.refurbishResourceOnCheckout(C3P0PooledConnectionPool.java:95)
at com.mchange.v2.resourcepool.BasicResourcePool.attemptRefurbishResourceOnCheckout(BasicResourcePool.java:891)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:222)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:170)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:172)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:58)
at com.mchange.v2.c3p0.ComboPooledDataSource.getConnection(ComboPooledDataSource.java:260)


and

Quote:
java.sql.SQLException: E/A-Exception: Socket closed
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:274)
at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:490)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1451)
at com.mchange.v2.sql.filter.FilterStatement.executeUpdate(FilterStatement.java:83)



All connections are closed with try/catch/finally like in the tomcat docs described. I'm quite sure that those exceptions aren't caused by c3p0, but any help how to solve this problem is very appreciated.

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 6:07 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Hi... Two things:

1) The first exception you're seeing aren't necessarily a problem, if it's infrequent. The pool is doing a Connection test on checkout, as you've configured, and it's failing. You test Connections because they sometime do fail.

2) It looks like you're using an older version of c3p0, and the second stack trace could be related to some bugs in older versions whereby Connections were prematurely closed following certain failures and exceptions. Please upgrade, if possible, to c3p0-0.9.0-pre6, which I hope is near release quality. (I say "I hope" because I could use some more feedback, hint, hint!)

Newer versions of c3p0 are drop-in replacements for older versions. Just download the binary release from http://sourceforge.net/projects/c3p0, and replace the old jar file with the new one. And please let me know how it works for you!

Steve
(c3p0 guy)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 8:05 am 
Newbie

Joined: Tue May 17, 2005 8:55 am
Posts: 11
Hi, thanks for the detailed answer.

I switched to c3p0-0.9.0-pre6 here is my config:

Code:
Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource@64e265d0[ acquireIncrement -> 5,
acquireRetryAttempts -> 30,
acquireRetryDelay -> 1000,
autoCommitOnClose -> false,
automaticTestTable -> null,
breakAfterAcquireFailure -> false,
checkoutTimeout -> 0,
connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester,
description -> null,
driverClass -> oracle.jdbc.driver.OracleDriver,
factoryClassLocation -> null,
forceIgnoreUnresolvedTransactions -> false,
identityToken -> 64e265d0,
idleConnectionTestPeriod -> 10,
initialPoolSize -> 25,
jdbcUrl -> jdbc:oracle:thin:@xxxx:xxx:xxxx,
loginTimeout -> 0,
maxIdleTime -> 0,
maxPoolSize -> 100,
maxStatements -> 0,
maxStatementsPerConnection -> 0,
minPoolSize -> 10,
numHelperThreads -> 10,
preferredTestQuery -> Select 1 from dual,
properties -> {user=******, password=******},
propertyCycle -> 300,
testConnectionOnCheckin -> false,
testConnectionOnCheckout -> true,
usesTraditionalReflectiveProxies -> false ] --



After doing two load test the following exceptions occured:

Code:
com.mchange.v2.resourcepool.BasicResourcePool (4_1403_1) D06B176D551B13DCEFE6AE93255C982B - com.mchange.v2.resourcepool.BasicResourcePool@1f0dc656 -- an attempt to checkout a resource was interrupted: some other thread must have either interrupted the Thread attempting checkout, or close() was called on the pool. --
java.lang.InterruptedException
   at java.lang.Object.wait(Native Method)
   at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:230)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:232)
   at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
   at com.mchange.v2.c3p0.ComboPooledDataSource.getConnection(ComboPooledDataSource.java:521)


java.sql.SQLException: An SQLException was provoked by the following failure: java.lang.InterruptedException
   at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:104)
   at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
   at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:62)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:238)
   at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
   at com.mchange.v2.c3p0.ComboPooledDataSource.getConnection(ComboPooledDataSource.java:521)


This exception only occurred once in many test-runs.


java.sql.SQLException: Connection is invalid

Occurred one time only too. Before swichting to c3p0-0.9.0-pre6 this exception was thrown quite frequently.

java.sql.SQLException: E/A-Exception: Socket closed

Stills occurrs very frequent, but only at one point of the application were long running queries are executed. No other sql-statements are affected, only one line of code. There are about 15 points in the application were sql is executed but only one point were the E/A Exception is thrown. I have checked all statements if they are closed with try/catch/finally several times. I can't tell how many sql-statements are executed in a test-run, but certainly several hundreds in about 3 minutes.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 1:39 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Blunted,

The InterruptedException is probably not a problem. It looks like when you considered your test done, you closed the DataSource, but a client was still waiting for a Connection. I'll modify the pool to be a bit less verbose in this expected case.

Also, as before, the "java.sql.SQLException: Connection is invalid", if it's the same as the one you showed before, probably just indicates that a Connection test failed, so the Connection has been discarded. This is a normal occurence, so long as its infrequent. (Does the Exception show more stack trace -- a root cause Exception -- with c3p0-0.9.0-pre6?)

The "java.sql.SQLException: E/A-Exception: Socket closed" is potentially a problem. I can't tell you why it's occuring; it's Oracle's driver that is throwing it. Here is one idea: Since this is a load test, there are probably lots of threads working concurrently. Make sure that while some threads are executing this SQL via a Statement, no other threads might somehow close() the Statement, it's parent Connection, or its parent pool. If, for example, your test periodically closes or destroys the ComboPooledDataSources it creates [using close( true ) or DataSources.forceDestroy( ... )], active Connections could be closed, and active queries interrupted. This could occur in any query, but if one query takes substantially longer than others, you would see it most frequently there. (It could be a similar issue to the InterruptedException -- perhaps when your test decides it's over, there are still active threads, and sometimes when you shut things down, these threads are in the middle of things and throw Exceptions.)

smiles,
Steve


Top
 Profile  
 
 Post subject: Null Pointer Exception
PostPosted: Thu May 19, 2005 9:31 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:04 pm
Posts: 64
Location: Melbourne, Australia
At the risk of stealing someone elses thread I get the following when I shut down my session factory. Is this normal?

Code:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] -- caught unexpected Exception while executing posted task.
java.lang.NullPointerException
   at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:538)
   at com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:38)
   at com.mchange.v2.c3p0.stmt.GooGooStatementCache$1.run(GooGooStatementCache.java:235)
   at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:148)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 10:41 am 
Newbie

Joined: Tue May 17, 2005 8:55 am
Posts: 11
mr. swaldman thanks for helping!

The "java.sql.SQLException: E/A-Exception: Socket closed" Exception
was caused by an error in the app.
Threads which were waiting for queries have been interrupted.

Everything is running fine now.
In about a hour we started about 9000 small (4 lines and 24 rows resultset) and 160 large (5527 lines and 241 rows) datawarehouse queries and transfered them to html. No connection was lost or broken. Every query was finished.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 12:30 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Blunted -- You are very welcome, and I'm glad things are working for you!

gstamp -- Please try c3p0-0.9.0-pre6; I'm pretty sure it will fix this. The issue is that when closing Connections with pooled Statements, the pooled Statements and the parent Connection were closed asynchronously. That means that sometimes the parent Connection would close before or simultaneous to child Statements closing. Several drivers do not handle this well, throwing NullPointerExceptions, or in the case of Oracle, sometimes deadlocking. c3p0-0.9.0-pre6 is modified to ensure that all child Statements close before Connection close is called. Good luck!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 5:54 am 
jTDS Developer
jTDS Developer

Joined: Tue Feb 24, 2004 5:36 pm
Posts: 70
Location: Bucharest, Romania
Blunted -- You're using a very old version of jTDS; you should be thinking about upgrading it. Newer versions don't exhibit this behavior, for example.

Steve -- As far as I can tell the error was occuring because two different threads were closing the Statement at the same time. This could indeed happen if the Statement and its Connection were closed at the same time.

Alin,
The jTDS Project.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 6:01 am 
Newbie

Joined: Tue May 17, 2005 8:55 am
Posts: 11
alin_sinpalean -- I don't think, that i jTDS. Why do you think, that i'm using it, maybe you mixed something up?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 6:37 am 
jTDS Developer
jTDS Developer

Joined: Tue Feb 24, 2004 5:36 pm
Posts: 70
Location: Bucharest, Romania
Blunted, you're right. Sorry for the confusion, my post was for gstamp. This is why hijacking posts is not a good idea. :o(

Alin.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.