我正在运行Grails 2.5.3(这个问题也在2.4.4中被观察到了),尽管我已经覆盖了DataSource.groovy中的一些默认连接池设置,但它并没有似乎正在使用它们。尽管将maxIdle设置为20,我们注意到我们的空闲连接增长到了〜200。为了说明,我运行了以下JMX命令:
$>get -b grails.dataSource:application=ts,dataSource=default,type=ConnectionPool MinIdle
#mbean = grails.dataSource:application=ts,dataSource=default,type=ConnectionPool:
MinIdle = 11;
$>get -b grails.dataSource:application=ts,dataSource=default,type=ConnectionPool NumIdle
#mbean = grails.dataSource:application=ts,dataSource=default,type=ConnectionPool:
NumIdle = 10;
摘自DataSource.groovy:
development {
development_base.call()
}
def development_base = {
dataSource {
url = <my url>
properties {
maxActive = 100
maxIdle = 20
minIdle = 11
minEvictableIdleTimeMillis=300000
timeBetweenEvictionRunsMillis=300000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
validationQueryTimeout = 10
removeAbandoned = true
removeAbandonedTimeout = 120
logAbandoned = true
abandonWhenPercentageFull = 60
suspectTimeout = 60
}
}
...
我也尝试将validationQuery更改为无效的东西(&#34; SELECT *来自foo&#34;因为foo不存在),但仍然可以运行查询。
请注意,我尝试将此配置移至BootStrap.groovy&amp; resources.groovy,但似乎有同样的效果。