Hi Chris, I have the connection pool defined in /etc/tomcat8/context.xml. Is that the wrong place the define it? Is what is defined there being copied into each application? I underplayed some sample application and I am now seeing 10 time the number of apps being deployed DB connections.
I am creating war files from eclipse to be deployed. Should I be creating a context file in eclipse so that it is included in the war file? If yes, should I copy the context.xml from from /etc/tomcat8 and then remove the pool definition from that file and just have it in the one in the war file? Responses to the questions are below. I have also implemented what Filip recommended, however after 24 hours the app start intermittently failing and there are only 2 open connections to the DB. This is in the log: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 79,290,702 milliseconds ago. The last packet sent successfully to the server was 79,290,702 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. 12-Jun-2015 16:51:55.659 WARNING [Tomcat JDBC Pool Cleaner[147643626:1434048550658]] org.apache.tomcat.jdbc.pool.ConnectionPool.abandon Connection has been abandoned PooledConnection[com.mysql.jdbc.JDBC4Connection@1fa3cd0e]:java.lang.Exception 79,290,702 milliseconds is ~22 hours if my calculations are correct. That is way way longer than what is specified. Here is what I added: logAbandoned="true" removeAbandoned="true" removeAbandonedTimeout="60" timeBetweenEvictionRunsMillis="15000" Thanks, Doug > On Jun 12, 2015, at 4:07 PM, Christopher Schultz > <ch...@christopherschultz.net> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Douglas, > > In addition to what Filip posted... > > On 6/11/15 12:18 PM, Douglas Schaible wrote: >> Good Day All, >> >> I am having a problem with a connection pool and I was hoping for >> some guidance. >> >> I have defined the connection pool below for two deployed >> applications to use. When I bounce the server I can see that it >> immediately crates 100 connections to the DB. (I am ok with this, >> but that is not what is specified in the config). > > When you start your application, does it load a bunch of stuff from > the database? If you are fetching lots of connections and not > returning them, you may see your connection count go up to 100 (the > maxTotal value). > No, it does not. Both of the apps on the server only make connections to the DB in doGet and they do not have an init method. >> Then when I access the application repeatedly very quickly new >> connections to the DB are created each time a page is called till >> it reaches about 150 and then future calls fail with the message >> "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: >> >> >> > Too many connections” logged by the server. > > I would have expected the pool to stop handing-out connections at 100. > > But, if you don't have removeAbandoned and you aren't returning the > connections properly, then the pool is full of connections that can't > be used. The server will make more than 100 connections, it will make about 150 and then start giving the error. > >> If we don’t place any extra load on the server the number of >> connections to the DB are reduced to 1 or 2 after 24 hours and you >> get the error "Timeout: Pool empty. Unable to fetch a connection >> in 30 seconds, none available[size:100; busy:100; idle:0; >> lastwait:30000].” from one of the applications and the other >> application continues to work just fine. > > The other application likely is using a different pool. Where is that > <Resource> defined? it uses the same pool. The pool is defined in /etc/tomcat8/context.xml. There is only one <Resource> > >> I believe that the DB, MySQL, is dropping the connection, but >> tomcat does not know that it has been dropped. >> >> I am looking for some guidance on how to tune this configuration. >> Any suggestions? >> >> >> <Resource name="jdbc/PDB" auth="Container" >> type="javax.sql.DataSource" >> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" >> initialSize="10" maxTotal="100" maxIdle="5" maxWaitMillis="10000" >> username=“xxxxxx" password=“xxxxxx" >> driverClassName="com.mysql.jdbc.Driver" >> url="jdbc:mysql://xxxxx.xxxxxx.us-east-1.rds.amazonaws.com”/> > > Your error message says "Unable to fetch a connection in 30 seconds", > but your maxWaitMillis is 10000 (10 seconds). Are you sure this is the > configuration being used? Yes. I am not sure why the timeout is different or more connections are made than expected. If I removed the configuration from context.xml and bounce the server all of the connection attempts the DB fail, so I believe that config is being used. > > - -chris > -----BEGIN PGP SIGNATURE----- > Comment: GPGTools - http://gpgtools.org > > iQIcBAEBCAAGBQJVe0oJAAoJEBzwKT+lPKRYqIYP/Rk23OUojZFYjhxMBzan18hV > KcT2znvisAupRth5zEKiHwABEDwhhy4YZiexyVmiixR91HuAtoI0PpvuhKs8j2uM > h1a+sdwWfgZz/PapiGr4FgXc0TlAc84RRlEG//5APeHkyQfE2XiCCwhkW7Q2hP3u > pcRirzbXbSnftwXAMCTdrr5p37bpO2pCFMxcw3lCk7galAatrfGg05mGWw8NbkTD > vL6iLepzK7krtk1QZskCRZ2TXRJ5H8UQjXMraLf8CEMxreP4gL9PNwLSUv2gCxrg > Gn0TAVagjYtTvBObVYZUrNQ0f97t3IMtwy1bfyXTxBul6pwSXiv9L9B2p63YDO6t > A13qjn3JJ4b3nkIm+ikejEkQdu1dVS+sNOlp2zKDV31wiMXQEHPIt5cUo8gmkI/O > 3RagTmCMQO8w/OaC96+vIAgHrnEeq+1bANpbGfghQHcwObwmJ3OeMFte7YvwlBBP > zaECgLOsNMHhvvllO3UrY2jEI6OQomE4FReuCr76txi0F6EdvHTO3OsVKL0Sz4Bd > 6L7OdpBSvENRNMpXWLSoyFdkm0HOmoA+HW7wJtCG5B06YXJO7RgHTkBk/3HQ0tIi > YUG661S4GkObOg0FEHYJshlvHmb9lOYVRlHqqlBut8hXoZrTlW3ac3Hk5Qb0d6Dh > zpbhalTCHqsbaR66OT3n > =4vP4 > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org >