DB Connection leaks in code
The following lines in code were referenced by the log entries produced by the 'logAbandoned=true' setting in the DBCP configuration.
These reveal DB Connections not being returned to the pool
Example log entries: https://gist.github.com/dsilvam/5ac8a009d713121810aa https://gist.github.com/dsilvam/26b29c72fa1037ee0862 https://gist.github.com/dsilvam/749ed1cbe02d07484ee1 https://gist.github.com/dsilvam/f4d86ea3e83f9214042d
Connection Leaks collected from log entries:
1. com.dotmarketing.business.IdentifierFactoryImpl.findByURI(IdentifierFactoryImpl.java:173)
2. com.dotmarketing.util.MaintenanceUtil.DBSearchAndReplace(MaintenanceUtil.java:484)
3. com.dotcms.enterprise.cluster.ServerFactoryImpl.getServer(SourceFile:80)
4. com.dotmarketing.factories.InodeFactory.getInodeOfClassByCondition(InodeFactory.java:861)
5. com.dotmarketing.portlets.virtuallinks.factories.VirtualLinkFactory.getVirtualLinkByURL(VirtualLinkFactory.java:43) VERY HIGH COUNT
6. com.dotcms.content.elasticsearch.business.ESContentFactoryImpl.loadField(ESContentFactoryImpl.java:101)
7. com.dotmarketing.factories.MultiTreeFactory.getMultiTreeByChild(MultiTreeFactory.java:211)
8. com.dotcms.content.elasticsearch.business.ESContentFactoryImpl.find(ESContentFactoryImpl.java:755)
9. com.dotmarketing.portlets.folders.business.FolderFactoryImpl.getSubFoldersTitleSort(FolderFactoryImpl.java:154)
10. com.dotmarketing.business.VersionableFactoryImpl.findContentletVersionInfoInDB(VersionableFactoryImpl.java:236)
11. com.dotmarketing.business.VersionableFactoryImpl.findWorkingVersion(VersionableFactoryImpl.java:52) (TRF has tons of this one)
12. at com.dotmarketing.db.HibernateUtil.load(HibernateUtil.java:341)
com.dotmarketing.factories.InodeFactory.getInode(InodeFactory.java:785)
13. com.dotmarketing.common.db.DotConnect.loadResult(DotConnect.java:232)
com.dotmarketing.portlets.contentlet.action.ImportAuditUtil.updateAuditRecord(ImportAuditUtil.java:194)
14. com.dotmarketing.common.db.DotConnect.loadResults(DotConnect.java:350)
com.dotcms.enterprise.publishing.PublishDateUpdater.updatePublishExpireDates(SourceFile:33)
15. at com.dotmarketing.db.DbConnectionFactory.getConnection(DbConnectionFactory.java:86)
at com.dotcms.enterprise.cluster.action.business.b.getAllServerActions(SourceFile:315)
16 org.apache.tomcat.dbcp.pool2.impl.DefaultPooledObject$AbandonedObjectCreatedException: Pooled object created 2015-10-12 13:37:01 +0000 by the following code has not been returned to the pool:
at org.apache.tomcat.dbcp.pool2.impl.DefaultPooledObject.allocate(DefaultPooledObject.java:196)
at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:449)
at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:360)
at org.apache.tomcat.dbcp.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:118)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1412)
at com.dotmarketing.db.DbConnectionFactory.getConnection(DbConnectionFactory.java:86)
at com.dotmarketing.db.HibernateUtil.getSession(HibernateUtil.java:630)
at com.dotmarketing.db.HibernateUtil.startTransaction(HibernateUtil.java:753)
at com.dotmarketing.portlets.contentlet.ajax.ContentletAjax.saveContent(ContentletAjax.java:1235)
17. at com.dotmarketing.db.HibernateUtil.startTransaction(HibernateUtil.java:753)
at com.dotcms.enterprise.priv.a.run(SourceFile:69)
18. com.dotmarketing.db.DbConnectionFactory.getConnection(DbConnectionFactory.java:86)
at com.dotmarketing.db.HibernateUtil.getSession(HibernateUtil.java:630)
at com.dotmarketing.db.HibernateUtil.startTransaction(HibernateUtil.java:753)
at com.dotcms.enterprise.priv.a.run(SourceFile:128)
19. com.dotcms.rest.IntegrityUtil.doesTableExist(IntegrityUtil.java:1145)
20. com.dotmarketing.factories.InodeFactory.getInodesOfClassByConditionAndOrderBy(InodeFactory.java:1453)
These are from where? What code version? In most cases, these should be closed by the
com.dotmarketing.listeners.HibernateSessionsListener on: https://github.com/dotCMS/core/blob/master-3.5/dotCMS/WEB-INF/web.xml#L306
Are there other listeners or are these being called outside of normal requests, for example, via a cron? If not, we will need to explore solutions here like the local transaction pattern that @jtesser loves so much. And we probably should write an annotation.
This was 3.3 but is practically the same code as current master, there was another logged abandoned connection from UpdateQuartzCronJobsServlet in 3.2.4 that I didn't included because it was fixed by this commit https://github.com/dotCMS/core/commit/5a2d6ac61334534a4c458f2e028793a970156a17#diff-bdafdfd8b38944ab2dbc767dc667e029.
Some of these are from Quartz Jobs and other from normal requests
https://my.dotcms.com/tickets/detail.dot?id=1049f2fe-48c5-48fe-b0e0-ba6b90d5371e
https://my.dotcms.com/tickets/detail.dot?id=f1d9b330-a85a-4845-b254-7bbb75129b68
Potential DB Connection Leaks, reported by client: https://my.dotcms.com/tickets/detail.dot?id=d46ddbc7-f36b-4c69-b755-d7c03f99c599
Stacktraces: https://gist.github.com/joseorsini/9d973d4117b7c84deb90310116f13e2a
Hi We've been waiting for around a year for a fix to this problem. Can you provide a patch? we can test it.
https://my.dotcms.com/ticket/leonteq-54
This continues to be a substantial problem particularly for installations on WebLogic and we have several support tickets open in relation to it.
The client that reported this one just upgraded to 3.7.1 and hit the same problem again. They had to implement the same fix that Daniel linked above. https://github.com/dotCMS/core/commit/5e547f7cca9536929fa74074248c08c6a7d8ba8b
It would be great if we can give some priority to this one.
Thanks!
Ticket: https://my.dotcms.com/tickets/detail.dot?id=fc09d9c5-e6aa-429b-ba6a-4a8379fbd026
This issue is causing a problem to us as well.
Would be great if we can get some visibility in terms of whether this can be looked at. Appreciate it!
Part of this issue has been addressed in Tickets like this one
https://github.com/dotCMS/core/issues/12100
@jdotcms can you point us to the other implementations of these Annotations on Github?
Thanks @joseorsini will update and test.
Was this issue resolved for dotcms 4.2.2?
A majority of these issues have - all the cases we could find.