Search code examples
javatomcatjdbcconnection-pooling

tomcat pool not resetting the pool. Getting too many connections error


I am using tomcat pool on tomcat 6. Following is the my resource definition:

 <Resource name="jdbc/DBConnectionFactory"
            auth="Container"
            type="javax.sql.DataSource"
            username="root"
         password="root"
        removeAbandoned="true"
        removeAbandonedTimeout="600"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost/sicad?autoReconnect=true"
               minIdle="3"
       maxActive="250"
       testWhileIdle="true"
       validationQuery="SELECT 1"
            maxIdle="10"
           timeBetweenEvictionRunsMillis="10000"
           minEvictableIdleTimeMillis="10000"
              maxWait="-1"
     />

Now, ideally after going to 250 connections all the idle connections should be removed, or atleast by some means mysql should not give too many connections error. Also, please note that if i do showprocesslist, there are hardly any concurrent queries going on. So i was thinking that timeBetweenEvictionRunsMillis should do the trick of removing idle connections and keep the pool alive. but as soon as 250 connections are set, the mysql starts throwing too many connections error. I was expecting that the tomcat pool, would remove any idle connections off the pool to keep the pool size reasonable. also note that its not that there are so many being created.

What's worse, this same configuration is working on developer machines and staging server + test server, but not on product server. also all the machines are clones of each other. i have rebooted machine, re-installed mysql, everything but all in vain.


Solution

  • Nothing worked, finally abandoned the hardware and same codebase, driver and mysql installation worked.