Saturday, 15 September 2012

java - Too many pool exhaustion errors with jdbc-pool -


I have an app that has jdbc-pool for handling mySQL connection in the previous month. Is starting to use. Before I was using Apache's commons-dcp I switched to jdbc-pool after reading some analysis, which showed it fast, better maintained, etc. However, I started by looking at that too many more users are viewing pool exhaust errors. / P>

I do not know that it is related to switching from commons to JDBC-pool, but it seems that the time is starting and I am thinking of building my product which Returns and gives it to people what it has to do to see DB errors.

I have written a document which helps in problem solving by adjusting the pool connection, maximizing wait, etc. However, a lot of people report pool exhaustion errors, even when their applications are essentially useless. Show a complete process list 1 connection in "sleep" 1 connection appears in the active.

I play a lot in both the application and the Dev environment and there is never a problem. I am better able to manage my mysql environment, but there is no such problem in rival products with weak pooling systems.

I've spent a lot of time reading jdbc and pooling docs, but am I doing something that will cause poor performance ?

These are examples of our DB connection codes, which are with the default that we use.

  // Once the application is started, the database is connected with the DataSource initDbPool () {String dns = "jdbc: mysql: //" + config.getString ( "Prism.mysql.hostname") + ":" + config.getString ("prism.mysql.port") + "/" + config.getString ("prism.mysql.database"); Pool = new datasource (); Pool.setDriverClassName ("com.mysql.jdbc.Driver"); Pool.setUrl (DNS); Pool.setUsername (/ * Username * /); Pool.setPassword (/ * Password * /); Pool.setInitialSize (10); Pool.setMaxActive (20); Pool.setMaxIdle (10); Pool.setMaxWait (30000); Pool.setRemoveAbandoned (right); Pool.setRemoveAbandonedTimeout (60); Return pool; } // is called from different classes to run the query for public static connection DBC () {connection con = null; Try {Con = pool.getConnection (); } Hold (SQLException e) {System.out.print ("database connection fail." + E.getMessage ()); E.printStackTrace (); } With return; }   

I never fancy more than questions. We are continuously running batch included questions but we have optimized that with a queue system and batch joining it is very fast and uses as much overhead as possible.

As I have seen that you have closed () but In the end, is not the end block, it means that if an exception occurs, the connection will be lost. I suspect that the commons-dhcp leak connection is not handled as jdbc-pool .

is removeAbandoned > configuration option, which is off by default, because this is the right thing ?? ¢ But as I think, it does not guarantee any guarantees, because it closes them from time to time if you have exceptions in a short time, then it can end the pool, so always a in the end Closing all connections in the block is a better way.

No comments:

Post a Comment