database-rider: Rider is leaking connections when cacheConnections = false
DBUnitExtension is leaking connections when the cacheConnections flag is false. If the are more than X tests and the connection pool has X connections the subsequent tests fails when waiting for checking out new connections.
The if the flag is set DataSetExecutorImpl.instance method doesn’t set the connectionHolder to the context which means that the beforeTestExecution must close the connection, which it doesn’t.
if (instance == null) {
instance = new DataSetExecutorImpl(executorId, connectionHolder,
DBUnitConfig.fromGlobalConfig().executorId(executorId));
log.debug("creating executor instance " + executorId);
executors.put(executorId, instance);
} else if (!instance.dbUnitConfig.isCacheConnection()) {
instance.setConnectionHolder(connectionHolder);
}
Also, even the cached connection seems to be never closed.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (9 by maintainers)
Commits related to this issue
- refs #332 Updates quarkus sample to use panache repository and add connection leak test — committed to database-rider/database-rider by rmpestano 3 years ago
- refs #332 - adds tests with cacheConnection=false and improve javadoc — committed to database-rider/database-rider by rmpestano 3 years ago
- refs #332 - small refactory in junit5 extension - adds tests with cacheConnection=false for springboot sample — committed to database-rider/database-rider by rmpestano 3 years ago
Hi @rmpestano. I think your exception is different from mine. My tests fails explicitly with a timeout exception when trying to checkout a connection, they all timeout after 30 seconds which is the timeout limit for Hikari connection checkout. I don’t think DBRider should manage any connection at all but return them when they are done with it. This to let the container run un-interfered since this will not happen in production. That’s why we were running with the connectionCached = false set.
Hi @hheg, I’ve added a test on junit5 module and indeed when
cacheConnection=falseit is failing after the first test is run. The second test will fail to retrieve information from the connection (probably because it is closed):Thanks for the heads up, I’ll investigate