oracle druid 连接池问题

cloohoo 发布于 2013/08/02 15:26
阅读 2K+
收藏 0

@wenshao 你好,想跟你请教个问题:

2013-08-02 14:53:52,890-[TS] ERROR http-bio-9901-exec-472 java.sql.Connection - Error calling Connection.prepareStatement:
com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60000
 at com.alibaba.druid.pool.DruidDataSource.pollLast(DruidDataSource.java:1076)
 at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:756)
 at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:644)
 at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4530)
 at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:659)
 at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4526)
 at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:626)
 at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:618)
 at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:79)
 at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
 at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:210)
 at $Proxy4.prepareStatement(Unknown Source)
 at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:601)
 at com.ibatis.common.jdbc.logging.ConnectionLogProxy.invoke(ConnectionLogProxy.java:53)
 at $Proxy5.prepareStatement(Unknown Source)
 at com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:497)
 at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:175)
 at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(MappedStatement.java:221)
 at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189)
 at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForObject(MappedStatement.java:120)
 at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:518)
 at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
 at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
 at com.std.struts2.ibatis.cert.ServiceForeignDAOImpl.checkActivationCertServlet(ServiceForeignDAOImpl.java:27)
 at com.std.struts2.domain.facade.ServiceForeignFacadeImpl.checkActivationCertServlet(ServiceForeignFacadeImpl.java:38)
 at com.std.service.foreign.servlet.AcountActivationServlet.doPost(AcountActivationServlet.java:126)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
 at java.lang.Thread.run(Thread.java:722)

我的连接池的配置:

   <property name="filters" value="stat" />
                <!-- 配置初始化大小、最小、最大 -->
                <!-- 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时 -->
             <property name="initialSize" value="600" />
             <!--  最小连接池数量 -->
             <property name="minIdle" value="200" />
             <!-- 最大连接池数量 -->
             <property name="maxActive" value="3500" />
             <!-- 配置获取连接等待超时的时间 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降
,如果需要可以通过配置useUnfairLock属性为true使用非公平锁。-->
             <property name="maxWait" value="60000" />
             <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
             <property name="timeBetweenEvictionRunsMillis" value="120000" />
             <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
             <property name="minEvictableIdleTimeMillis" value="300000" />
             <!-- 用来检测连接是否有效的sql,要求是一个查询语句。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会其作用 -->
             <property name="validationQuery" value="SELECT 1" />
             <!-- 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执>行validationQuery检测连接是否有效。 -->
             <property name="testWhileIdle" value="false" />
             <!-- 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能 -->
             <property name="testOnBorrow" value="false" />
             <!-- 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能 -->
             <property name="testOnReturn" value="false" />
             <!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
             <!-- 是否缓存preparedStatement,也就是PSCache。 PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql下建议关闭 -->
             <property name="poolPreparedStatements" value="true" />
             <property name="maxPoolPreparedStatementPerConnectionSize" value="2000" />

   我的版本是:druid-0.2.9.jar

上述问题在做压力测试一直发生上述问题,

我的数据库的配置:session数的值是10000个,每个session的开启的游标数是10000个,

通过select count(*) from gv$session 查的session数是2312,

select count(*) from v$open_cursor;查出的游标是8522个

所以通过上述语句查的时候,我的数据库的连接远远没有耗尽,如果使用其它的测试程序或者客户端工具都可以连接上数据库

请帮忙查看下,谢谢.

 

加载中
返回顶部
顶部