Closed mychao closed 2 years ago
maxWait太小了, 改成15000吧
@wendal maxWait是获取连接的最大等待时间,获取连接的时间应该很快吧,设置15000是不是太大了?
建oracle连接的时候,有时候很慢
我这边也经常出现这个问题,怎么解决的
@wendal ERROR http-nio-8080-exec-105 org.hibernate.engine.jdbc.spi.SqlExceptionHelper - wait millis 60015, active 2, maxActive 100, creating 1 用的是MySQL Server 5.7
@huangmaomao 是不是网络波动? mysql在同一个机器嘛?
话说,为啥这个issue会@我的呢??
其实你们想at的人是 @wenshao 吧, 虽然我也给druid提交过代码...
我做的是nutz系列的java框架 例如 https://github.com/nutzam/nutz 和 https://github.com/nutzam/nutzboot
额,是在同一台机器上面@wenshao
creating=1标识,在建立物理连接中,是不是数据库有什么问题导致建立连接很慢?
数据库和服务是在一台机器上面的,数据可以正常连接访问,服务重启之后就可以拿到连接
@wenshao 网络带宽是2M的,之前有时候出现这个问题,我把版本更新到1.1.1之后用了二周,今天就频繁出现这个问题,重启服务也不行,数据库可以正常访问
买一个阿里云的rds试试?
主要是什么原因引起的呢?这个是客户的阿里云服务器,要知道原因才好给客户建议
看不出,从报错看到的信息是物理连接在创建中
我出现这个问题!!连接池配置如下: 1 #连接池配置 initialSize: 110 minIdle: 110 maxActive: 1000 maxWait: 5000 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 FROM DUAL testWhileIdle: true testOnBorrow: false testOnReturn: false removeAbandoned: true pool-prepared-statements: true max-pool-prepared-statement-per-connection-size: 50 2 报错信息如下: Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 5258, active 120, maxActive 1000, creating 0 at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1379) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1198) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4619) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.logging.LogFilter.dataSource_getConnection(LogFilter.java:874) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4615) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.FilterAdapter.dataSource_getConnection(FilterAdapter.java:2745) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4615) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.FilterAdapter.dataSource_getConnection(FilterAdapter.java:2745) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4615) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:666) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4615) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1176) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1168) ~[druid-1.1.3.jar!/:1.1.3] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104) ~[druid-1.1.3.jar!/:1.1.3] at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) ~[spring-jdbc-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) ~[spring-jdbc-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:84) ~[mybatis-spring-1.3.0.jar!/:1.3.0] at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:70) ~[mybatis-spring-1.3.0.jar!/:1.3.0] at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:337) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) ~[mybatis-3.4.0.jar!/:3.4.0] at sun.reflect.GeneratedMethodAccessor188.invoke(Unknown Source) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434) ~[mybatis-spring-1.3.0.jar!/:1.3.0] at com.sun.proxy.$Proxy93.selectOne(Unknown Source) ~[?:?] at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:167) ~[mybatis-spring-1.3.0.jar!/:1.3.0] at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75) ~[mybatis-3.4.0.jar!/:3.4.0] at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) ~[mybatis-3.4.0.jar!/:3.4.0] at com.sun.proxy.$Proxy102.findUserByPhone(Unknown Source) ~[?:?] at com.qtec.router.server.service.user.RouterUserService.findUserByPhone(RouterUserService.java:70) ~[classes!/:1.0-Dev] 3 还有这样的错误信息:
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) ~[mybatis-3.4.0.jar!/:3.4.0]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150) ~[mybatis-3.4.0.jar!/:3.4.0]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.0.jar!/:3.4.0]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) ~[mybatis-3.4.0.jar!/:3.4.0]
at sun.reflect.GeneratedMethodAccessor188.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434) ~[mybatis-spring-1.3.0.jar!/:1.3.0]
at com.sun.proxy.$Proxy93.selectOne(Unknown Source) ~[?:?]
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:167) ~[mybatis-spring-1.3.0.jar!/:1.3.0]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75) ~[mybatis-3.4.0.jar!/:3.4.0]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) ~[mybatis-3.4.0.jar!/:3.4.0]
at com.sun.proxy.$Proxy102.findUserByPhone(Unknown Source) ~[?:?]
at com.qtec.router.server.service.user.RouterUserService.findUserByPhone(RouterUserService.java:70) ~[classes!/:1.0-Dev]
at com.qtec.router.server.service.user.RouterUserService$$FastClassBySpringCGLIB$$9941f5fd.invoke(<generated>) ~[classes!/:1.0-Dev]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:669) ~[spring-aop-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at com.qtec.router.server.service.user.RouterUserService$$EnhancerBySpringCGLIB$$ee6d5337.findUserByPhone(<generated>) ~[classes!/:1.0-Dev]
at com.qtec.router.server.service.user.RouterUserService$$FastClassBySpringCGLIB$$9941f5fd.invoke(<generated>) ~[classes!/:1.0-Dev]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:669) ~[spring-aop-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at com.qtec.router.server.service.user.RouterUserService$$EnhancerBySpringCGLIB$$95b89e73.findUserByPhone(<generated>) ~[classes!/:1.0-Dev]
at com.qtec.router.server.controller.login.LoginController.login(LoginController.java:99) ~[classes!/:1.0-Dev]
at com.qtec.router.server.controller.login.LoginController$$FastClassBySpringCGLIB$$263125b4.invoke(<generated>) ~[classes!/:1.0-Dev]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) ~[spring-aop-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at com.alibaba.druid.support.spring.stat.DruidStatInterceptor.invoke(DruidStatInterceptor.java:72) ~[druid-1.1.3.jar!/:1.1.3]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) ~[spring-aop-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at com.qtec.router.server.controller.login.LoginController$$EnhancerBySpringCGLIB$$108f9516.login(<generated>) ~[classes!/:1.0-Dev]
... 68 more
4 数据库本身设置的最大连接数为3000:SHOW VARIABLES like 'max_con%' 结果是3000
补充信息,当前使用版本是:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.3</version>
</dependency>
补充信息:数据库服务器打印出来的错误日志是: 2017-11-28T03:26:05.495523Z 20555 [Note] Aborted connection 20555 to db: 'xxxt' user: 'xxx' host: '192.168.92.53' (Got an error reading communication packets)
@wenshao 麻烦帮忙看一下
看是数据库挂了哦
@wenshao 数据库是正常服务啊,后续的请求没有问题!为什么连接数远没有达到最大值,拿不到空闲的连接,没有新建,而是等待空闲的
org.apache.ibatis.exceptions.PersistenceException:
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
active为0,还是抛出拿不到连接的异常,就突然出现那么几十次,然后又没出现过了
@lg84300329 能问下这个是怎么解决的吗?
一樣的錯誤,wait millis 60000, active 0, maxActive 20, creating 0] with root cause,求問怎麽解決的。我連的是oracle。 (Ps:oracle被人搞過之後就出了問題了,之前可以訪問的接口都訪問不了,有沒有可能是oracle庫的問題)
同样遇到了active 0,Could not get JDBC connection的问题,数据库为postgresql,druid 版本:1.0.20。
@geeksun 你这个解决了吗。遇到一样的问题了。
网络断开 , 数据库重建连接池的代码在哪个地方呢
com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 60004, active 150, maxActive 150 at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1155) at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:977) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544) at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:662) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:955) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:947)
Could not open JDBC Connection for transaction; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 30000, active 0, maxActive 10, creating 1 at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:289) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:447) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
@wenshao我这边也经常报这类错误,请问有什么解决办法或者是排查思路吗?谢谢了 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
###还有一个经常报Communications link failure错误,这个是网络问题吗? com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at sun.reflect.GeneratedConstructorAccessor122.newInstance(Unknown Source) ~[?:?] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.7.0_79] at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[?:1.7.0_79] at com.mysql.jdbc.Util.handleNewInstance(Util.java:377) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1036) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:627) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1013) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:790) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44) ~[mysql-connector-java-5.1.34.jar:5.1.34] at sun.reflect.GeneratedConstructorAccessor118.newInstance(Unknown Source) ~[?:?] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.7.0_79] at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[?:1.7.0_79] at com.mysql.jdbc.Util.handleNewInstance(Util.java:377) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:148) ~[druid-1.1.0.jar:1.1.0] at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:217) ~[druid-1.1.0.jar:1.1.0] at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142) ~[druid-1.1.0.jar:1.1.0] at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1466) ~[druid-1.1.0.jar:1.1.0] at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1529) ~[druid-1.1.0.jar:1.1.0] at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2178) [druid-1.1.0.jar:1.1.0] Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2914) ~[mysql-connector-java-5.1.34.jar:5.1.34] at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:559) ~[mysql-connector-java-5.1.34.jar:5.1.34] ... 18 more
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConne
ctionException: Could not get JDBC Connection; nested exception is com.alibaba.d
ruid.pool.GetConnectionTimeoutException: wait millis 60011, active 0, maxActive
20, runningSqlCount 1 : SELECT d.option_name AS meno,dt.print_time printTime,dt.
line_group_id lineGroupId,dt.id FROM t_delivery_time dt LEFT JOIN t_dictionary d
ON d.id = dt.line_group_id where dt.`auto_print_status`=0
runningSqlCount 1 : select `status` from t_printer_conf where type_code=?
### The error may exist in class path resource [mapper/PrinterConfMapper.xml]
### The error may involve com.tramy.print.mapper.PrintConfMapper.queryPrinterLin
eGroup
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not
get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTim
eoutException: wait millis 60011, active 0, maxActive 20, runningSqlCount 1 : SE
LECT d.option_name AS meno,dt.print_time printTime,dt.line_group_id lineGroupId,
dt.id FROM t_delivery_time dt LEFT JOIN t_dictionary d ON d.id = dt.line_group_i
d where dt.`auto_print_status`=0
runningSqlCount 1 : select `status` from t_printer_conf where type_code=?
同样遇到这个问题,怎么解决
jdbc:mysql://xxxxxxx.:xxx/tablename?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=GMT%2B8&noAccessToProcedureBodies=true&autoReconnect=true&failOverReadOnly=false url参数改成这样,连接断开有重连,情况好些。增加autoReconnect和failOverReadOnly
那个。。有点尴尬。。。直说了吧
兄弟,是不是开了vpn?还选择了全局模式
??
我是这样解决的 :)
也是同样的问题,不知道什么原因,有人解决吗,暂时先放弃druid了
maxWait太小了, 改成15000吧
您好,我们系统目前也会时不时的出现这个问题。我们maxWait是500; 如果把maxWait改太大,可能会导致请求的时间都花费在了获取连接上。
creating=1标识,在建立物理连接中,是不是数据库有什么问题导致建立连接很慢?
@wenshao 你好,日志打印出来creating是1,说明是在holder = new DruidConnectionHolder(this, pyConnInfo);的时候失败了吧,如果这句正常没问题的话,creatingCount会变成0 呀。如果是失败,您这边知道大概的失败原因吗
// 进入if之后,creatingCount变成1
if (creatingCountUpdater.compareAndSet(this, 0, 1)) {
PhysicalConnectionInfo pyConnInfo = DruidDataSource.this.createPhysicalConnection();
holder = new DruidConnectionHolder(this, pyConnInfo);
holder.lastActiveTimeMillis = System.currentTimeMillis();
// 此处creatingCount变为0
creatingCountUpdater.decrementAndGet(this);
directCreateCountUpdater.incrementAndGet(this);
// 此处省略代码...
}
这个问题我觉得应该是数据库负载比较大,数据库连接不够用了(我们的线上应用主库写操作非常大),或者是网络有问题导致的创建连接失败,超时。有问题的朋友可以看看sql监控的慢查询,我们线上应用有很多的慢查询(大部分耗时30S)。代码优化后将某条sql(频繁更新某个表)的使用率降低了90%左右,上线后几乎没有这个报错了。仅供参考!
@wenshao 我们场景是使用druid连接池获取connection后使用jdbc对mysql读写,因为这样比较轻量。我们不希望滥用数据库连接,因为设置的maxActive是50。计划任务会起100个线程,每个线程从datasource获取connection,执行完批量任务后会调用connection.close()返还连接给连接池。但是现在的问题是执行完50个线程之后,会报getConnectionTimeoutException,我理解应该是前面的50个线程还没有释放连接,导致后面的线程获取不到。请问是什么参数设置的不对吗,或者需要设置什么参数来解决这个问题?
@wenshao 我们场景是使用druid连接池获取connection后使用jdbc对mysql读写,因为这样比较轻量。我们不希望滥用数据库连接,因为设置的maxActive是50。计划任务会起100个线程,每个线程从datasource获取connection,执行完批量任务后会调用connection.close()返还连接给连接池。但是现在的问题是执行完50个线程之后,会报getConnectionTimeoutException,我理解应该是前面的50个线程还没有释放连接,导致后面的线程获取不到。请问是什么参数设置的不对吗,或者需要设置什么参数来解决这个问题?
现在druid版本是1.1.5,maxIdle是50,minIdle是50,testOnBorrow=false,testOnReturn=false,removeAbandoned=true
我有一种情况会报这个错, 就是服务器资源不够, 例如只有2核, 结果跑的时候应用非常占资源, 然后就出现了一堆的interrupt, 就获取不到connection了. 加大配置到4核就OK了
com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 2000, active 0, maxActive 30, creating 0 同样遇到这个问题,有人解决了吗?
@mychao @wenshao @huangmaomao @wendal “com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 2000, active 0, maxActive 30, creating 0” 同样遇到这个问题,有什么解决方案吗?
资源不足导致的问题
这个问题官方能出来回复一下吗?生产环境真是不敢启用呀
也碰到这个问题了
也碰到类似问题,谁能给个方案吗 ?
同问
同问
同问
大佬,请问这个问题有解决吗?druid-1.1.16仍然会出现,而且会出现 数据库看到的连接数 < minIdle的情况。 @wenshao
同问
@wendal 请帮忙看下,谢谢。 数据库运行正常,但是突然出现了获取连接超时的异常,异常堆栈信息: Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 1000, active 5, maxActive 200, creating 1 at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1422) at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1241) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1221) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1211) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:105) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)