0

I have and application that manages hundreds of databases and I use a connection pool for every database. Sometimes one of the databases becomes locked and all the operations that involves queries on that connection pool are locked. It is very unusual but happens. I'm using MariaDb, Tomcat and Spring framework. The memory dump of the server when that happens shows me the problem but I don't understand what causes that. Only the pool that is locking is a GC Root for the garbage collector. Anyone has a clue of what can cause this? Thanks

I made a memory dump and I found this:

org.springframework.jdbc.core.JdbcTemplate$$Lambda$2684#4 [GC root - Java frame]  
org.springframework.jdbc.core.JdbcTemplate#142 [GC root - Java frame]
dataSource = org.apache.commons.dbcp2.BasicDataSource#143 [GC root - Java frame]
dataSource = org.apache.commons.dbcp2.PoolingDataSource#142 [GC root - Java frame]
dataSource in org.springframework.jdbc.datasource.DataSourceTransactionManager#142 [GC root - Java frame]
connectionPool = org.apache.commons.pool2.impl.GenericObjectPool#147 [GC root - Java frame]
idleObjects = org.apache.commons.pool2.impl.LinkedBlockingDeque#147 [GC root - Java frame]
  • Ditch DBCP2 as a pool and use something newer/better like HikariCP instead. That being said if your pool is exhausted you probably have a connection leak somewhere (generally code that does things like `datasource.getCOnnection` without closing it or even worse `jdbcTemplate.getDataSource().getConnection`. – M. Deinum Aug 15 '23 at 06:49

0 Answers0