有时在Tomcat8.5中发现以下日志。当我们观察错误堆栈跟踪时,我们没有在代码中发现任何连接泄漏,但有时会捕获日志。我无法识别这是否是连接泄漏或任何其他问题的迹象。
Pooled object created 2018-11-13 11:00:01 -0800 by the following code
has not been returned to the pool:
org.apache.tomcat.dbcp.pool2.impl.ThrowableCallStack$Snapshot at
org.apache.tomcat.dbcp.pool2.impl.ThrowableCallStack.fillInStackTrace(ThrowableCallStack.java:71)
at org.apache.tomcat.dbcp.pool2.impl.DefaultPooledObject.allocate(DefaultPooledObject.java:192)
at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:455)
at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:361)
at org.apache.tomcat.dbcp.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:134)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1543)
at com.sample.test.db.SlaveDBConnection.initiateConnection(SlaveDBConnection.java:40)
at com.sample.test.db.SlaveDBConnection.<init>(SlaveDBConnection.java:25)
at com.sample.test.db.DBFactory.getDBObject(DBFactory.java:80)
at com.sample.test.app.model.dao.UserDAOImpl.getUserData(UserDAOImpl.java:1795)
at org.apache.jsp.getData_jsp._jspService(getData_jsp.java:298)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.MFilter.doFilter(MFilter.java:52)
字符串
这里是什么是ment由org.apache.tomcat.dbcp.pool2.impl.ThrowableCallStack$Snapshot
和我们什么时候得到这个问题。我们如何重现这个问题?
2条答案
按热度按时间2nc8po8w1#
您正在运行的Web应用程序为资源池激活了
logAbandoned
标志。每当应用程序获取新的JDBC连接时,池将占用(开销)时间并在内存中记录调用堆栈跟踪。每当它后来意识到一个JDBC连接没有被正确关闭时,它将获取该堆栈跟踪快照并将其转储到日志中,指向获取未安全关闭的连接的确切位置(Java源文件和行,如果为调试而编译),冒着连接泄漏的风险。可再现性在很大程度上取决于应用程序实际上在做什么以及什么时候做。如果有几个附带条件发生这种情况,可能很难重现,但您可以从堆栈跟踪中读取它发生的实际位置,并可能分析源代码,找到有罪的代码行,甚至可能归咎于开发人员;- )
有关进一步阅读,请参阅此处的Tomcat文档。
ryoqjall2#
如果您将“logAbandoned”设置为“false”,则不会再次收到这些消息。即使您收到这些消息,它似乎也不会对数据库连接池产生负面影响。