I'm monitoring a JDBC connection pool under GlassFish 4.0 and am finding that the 'numconnused' reported by the monitor is always much higher than the number of open connections that MySQL reports via SHOW PROCESSLIST. For instance, MySQL will report ~25 open connections but GlassFish says there are over 50 'numconnused'. The on-line doc. leads me that these value should be about the same at any given moment. Any ideas as to why these two values should be wildly off?
-
connection pooling voodoo – Drew Jul 14 '15 at 01:28
-
Note quite, I found this page: http://stackoverflow.com/questions/10047207/making-datasource-in-glassfish – foboz Jul 14 '15 at 11:32
-
So what is the Executive Summary foboz – Drew Jul 14 '15 at 11:36
-
We were using a ConnectionPoolDataSource which uses whatever the MySQL JDBC driver has decided to use for its pooling implementation. Given that we only configured the driver with the bare minimum it needed to connect to the database this probably leaves the “pooling” aspect of things improperly configured. – foboz Jul 14 '15 at 11:38
-
Awesome. Thx for sharing! – Drew Jul 14 '15 at 11:39
1 Answers
I found this page: Making datasource in Glassfish
“ConnectionPoolDataSource is used to give access to PooledConnection which implements native pooling by JDBC driver. In this case application server can implement connections pooling using this native interface.”
“DataSource: A DataSource object is a factory for Connection objects. When using simple DataSource, appserver uses its own pooling instead of native.”
We were using a ConnectionPoolDataSource which uses whatever the MySQL JDBC driver has decided to use for its pooling implementation. Given that we only configured the driver with the bare minimum it needed to connect to the database this probably leaves the “pooling” aspect of things improperly configured.
This would likely account of the strange discrepancies I’ve been seeing between the number of ‘numconnused’ connections reported by GlassFish and the number of actual, open connections reported by MySQL.
I’ve changed pooling to use a DataSource and am now seeing that the number of ‘numconnused’ connections is close of what MySQL is reporting (connections with no or low sleep time).