我收到池错误超时等待空闲对象 [英] I am getting pool error Timeout waiting for idle object

查看:100
本文介绍了我收到池错误超时等待空闲对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  <Resource name="jdbc/name" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="root" password="root" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql:url?autoReconnect=true"/> 

我在Tomcat服务器中使用以上语句创建了连接池.

I created connection pool using the above statement in Tomcat server.

某些android应用正在使用网络服务与我的应用连接.通过网络服务,我正在发送和接收一些数据. 我收到错误

Some android app is connecting with my application using web service.Through web service i am sending and receiving some data. I am getting the error

SQLState: null
[2013-12-05 14:13:06,156]ERROR069688[http-8080-10] - org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:78) -
 Cannot get a connection, pool error Timeout waiting for idle object

我看到了连接池异常:无法建立连接,池错误超时等待空闲对象.

但是对我来说毫无头绪.

But no clue for me.

这是什么原因

预先感谢...

推荐答案

此异常表明,池管理器无法与正在等待的请求者建立可行的连接,并且maxWait已通过,因此触发了超时.有多种潜在原因,但通常分为两大类:

This exception is stating that the pool manager cannot produce a viable connection to a waiting requester and the maxWait has passed therefore triggering a timeout. There are several potential causes, but they usually fall into two broad categories:

  1. 数据库已关闭或无法访问.这可能是因为您忘记启动它,或者它崩溃了,或者您和数据库之间的网络已停止工作.但是从根本上说,池无法提供有效的新连接,因此请求者坐下来等待新连接的时间超过了超时时间,因此放弃了.这通常是不太可能的情况,因为您通常会在发生这种情况时看到其他错误.

  1. The DB is down or unreachable. This could be because you forgot to start it, or it crashed, or the network between you and the DB has stopped working. But basically, the pool has been unable to provide a valid new connection and so the requester has sat waiting for a new connection for longer than the timeout and has given up. This is usually the less likely case cause you usually see other errors when this happens.

连接池(设置为最大活动100个)已断开连接.这可能是由于需求量高引起的,也可能是连接泄漏的征兆,其中连接永远不会返回到池中,最终您超过了最大连接限制.这是更可能的原因...通常是由于在使用完数据库资源后没有关闭数据库资源而导致连接泄漏.

The connection pool (which is set to 100 max active) is out of connections. This could be due to high demand volume, or it could be an indication of a connection leak where connections are never returned to the pool and eventually you exceed the max connections limit. This is the more likely cause... usually a connection leak due to not closing db resources when you're done with them.

有时1和2会创建此方案,如果说DB在查询停止执行时遇到错误.发生这种情况时,就像连接泄漏一样,因为新连接断开并阻塞了对数据库的查询,并且从不释放.最终所有连接都处于活动状态,下一个请求连接的线程将放入等待队列中,因为没有更多的连接可供分配.由于数据库已关闭,直到第一个在等待队列中超时的请求者之后,您才能看到其他任何异常.当Oracle DB后端崩溃时,我们经常会偶尔使用Oracle UCP.

Sometimes 1 and 2 to create this scenario if say the DB encounters an error where queries stop being executed. When that happens, its like a connection leak because new connections go out and block on a query against the DB and are never released. Eventually all the connections are active and the next thread to request a connection will be put in the wait queue because there are no more connections to give out. Since the DB's hosed, you won't see any other exceptions until the first requester who times out in the wait queue. We used to see this occasionally using Oracle UCP when the Oracle DB backend crashed.

我建议使用JConsole监视发生这种情况时的数据库池大小,并确定触发此错误的上述两种原因中的哪一种.然后,您可以尝试修复连接或操纵池大小/超时参数以适应实际需求(还可以在Tomcat中操纵连接器参数以减少对应用程序的总体需求).如果您在Tomcat中运行,通常可以只运行JConsole(位于JDK bin目录中)并附加到tomcat进程,然后通过JMX控制台查找在何处找到池大小...通常取决于数据源类型(dbcp vs oracle ucp vs等).然后,您可以双击字段值以对其进行绘制,以便随时间跟踪它们.

I'd recommend using JConsole to monitor the DB pool sizes when this happens and determine which of the two above categories of causes this error is triggered by. And then, you can try to fix the connection or manipulate the pool size/timeout parameters to accommodate the real demand (you can also manipulate connector parameters in Tomcat to reduce the overall demand on the application). If you're running in Tomcat, you can usually just run JConsole (which is in the JDK bin directory) and attach to the tomcat process and then just look through the JMX console to find where the pool size is found... that usually depends on the data source type (dbcp vs oracle ucp vs etc). Then, you can double click on the field values to plot them so you can track them over time.

此外,您可能需要在Tomcat中启用JMX才能使JConsole JMX监视正常工作.

Also, you may need to enable JMX in Tomcat for JConsole JMX monitoring to work.

这篇关于我收到池错误超时等待空闲对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆