alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.97k stars 8.58k forks source link

skip not validate connection 一直无法解决 #1437

Open Z4Stones opened 8 years ago

Z4Stones commented 8 years ago

隔一段时间没有操作后session超时,退出后重新登录就会卡住,提示如下: 2016-09-28 15:43:21 -7234176 [http-bio-8080-exec-5] DEBUG - DispatcherServlet with name 'springMvc' processing POST request for [/login/login_login] 2016-09-28 15:43:21 -7234177 [http-bio-8080-exec-5] DEBUG - Looking up handler method for path /login/login_login 2016-09-28 15:43:21 -7234178 [http-bio-8080-exec-5] DEBUG - Returning handler method [public java.lang.String com.ydz.controller.system.LoginController.login(javax.servlet.http.HttpServletRequest) throws java.lang.Exception] 2016-09-28 15:43:21 -7234178 [http-bio-8080-exec-5] DEBUG - Returning cached instance of singleton bean 'loginController' 2016-09-28 15:43:21 -7234179 [http-bio-8080-exec-5] DEBUG - Skip CORS processing, request is a same-origin one 2016-09-28 15:43:21 -7234181 [http-bio-8080-exec-5] DEBUG - Using transaction object [org.springframework.jdbc.datasource.DataSourceTransactionManager$DataSourceTransactionObject@705cea7] 2016-09-28 15:43:21 -7234181 [http-bio-8080-exec-5] DEBUG - Creating new transaction with name [com.ydz.service.system.UserService.getAuthorByUserId]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-java.lang.Exception 2016-09-28 15:43:41 -7254770 [http-bio-8080-exec-5] DEBUG - skip not validate connection. 2016-09-28 15:44:33 -7306551 [http-bio-8080-exec-5] DEBUG - skip not validate connection. 2016-09-28 15:44:33 -7306589 [http-bio-8080-exec-5] DEBUG - Acquired Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@74b4cfb7] for JDBC transaction 2016-09-28 15:44:33 -7306589 [http-bio-8080-exec-5] DEBUG - Switching JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@74b4cfb7] to manual commit

看了很多帖子都没有解决这个问题,哪位大神知道。

yufeng217 commented 6 years ago

我也遇到类似的问题。 环境是:oracle 11g + tomcat8.35.2 + druid1.1.10 + jfinal-java8-3.4,linux CentOS 6.5。

反复尝试改变 druid 的参数(初始连接池大小、最小空闲连接数、连接等待超时的时间、指定每个连接上PSCache的大小)都不成。

最后,写了一个轮循,每分钟执行 select 1 from dual; SQL 语句,使其保持有效连接,观察了 1 天没有问题。

话说,druid 在新申请连接时检查是否有效,那么再检查空闲连接时,也检查一下是否有效,是不是就解决了这个问题呢?免的开发者再写一个轮循了。