Get connection pool status with grails -
i have webservice built grails connects mysql database. since upgraded 2.4.3 i've had problems connectionpool not releasing connections, resulting in exception:
org.apache.tomcat.jdbc.pool.poolexhaustedexception: [http-bio-8080-exec-216] timeout: pool empty. unable fetch connection in 30 seconds, none available[size:50; busy:50; idle:0; lastwait:30000]
this datasources.groovy
datasource { url = "jdbc:mysql://..." username = "xxx" password = "xxx" pooled = true properties { maxactive = 50 maxage = 10 * 60000 timebetweenevictionrunsmillis = 5000 minevictableidletimemillis = 60000 numtestsperevictionrun=3 testonborrow=true testwhileidle=true testonreturn=true validationquery="select 1" } } datasource_survey { url = "jdbc:mysql://..." username = "xxx" password = "xxx" pooled = true properties { maxactive = 50 maxage = 10 * 60000 timebetweenevictionrunsmillis = 5000 minevictableidletimemillis = 60000 numtestsperevictionrun=3 testonborrow=true testwhileidle=true testonreturn=true validationquery="select 1" } }
i've read grails jira , people seem have similar problems. haven't been able prepare info provided there.
accessing status of connectionpool help debugging great deal. how can check status of connectionpool see how many connections idle/busy during runtime?
the connection pool registered javax.sql.datasource
interface has methods getting connection
(one username/password , 1 without), accessing log writer, , getting/setting login timout. else left tehe vendor decide, , there's little commonality between vendors in methods configuring pools initially, , working , monitorring them throughout app run.
so need find out library used pool , utilize api. ideally simple accessing datasource
bean (that's easy, dependency-inject service/controller/etc. bean - class-scope field, in case def datasource
) , printing class name. wrap datasource in few proxies add together of import behaviors, not easy access
you're in luck though - cases this, leave original unproxied instance lone , register datasourceunproxied
bean can dependency-inject (just don't access of connections, information).
for long time used commons-pool manage datasources, while switched tomcat jdbc pool because benchmark tests showed it's faster other looked @ (including c3p0), , configuration methods based on commons-pool's, basicallly drop-in replacement important performance boost , more configurability.
grails connection-pooling
No comments:
Post a Comment