DB Connection idle timeout isn't honored in Lucee 6

Hey folks,

We’re upgrading what’s left of our CFML application to from Lucee 5 → Lucee 6, and we’ve seen a behavior change around database connections.

All of our hosted environments proactively (database-side) close database connections after five minutes (typical best practice for managing RAM utilization), so we’ve long had Lucee configured to consider idle connections eviction candidates after four minutes:

this.datasources['whatever'] = {
        ....some stuff...
        , connectionTimeout: 4
        ...other stuff...
};

That doesn’t look to be doing anything at all in Lucee 6, and we’re running into dead connections.

I believe the cause is in ConfigImpl’s configuration of GenericObjectPoolConfig instances. It looks like Lucee has hard-coded a number of values (minEvictableIdleTimeMillis, timeBetweenEvictionRunsMillis, etc.) to 0, meaning these commonly-needed pooling properties are simply not doing anything.

In other words, there’s at least a bug here (Lucee is using a hard-coded 0 for minEvictableIdleTimeMillis and sets no time between eviction runs, so even with an evictable time, it’d never do anything).

We’ve worked around this by writing our own code that introspects the pools at runtime, reconfiguring them directly, but is there any plan to expose these properties officially? I get that Lucee has to support the web-based configuration forms, but I’d strongly recommend looking at how other Java-based frameworks (Micronaut, Spring Boot) allow these to be set through convention within code.

Having spent the morning with the Lucee source code, I don’t think it’d be hard to allow a similar approach, even if it’s just adding more properties to the DataSource class for these:

this.datasources['whatever'] = {
		...stuff...
		, minIdle: 5,
		, maxIdle: 25,
		, maxWaitMillis: 10000,
		, timeBetweenEvictionRunsMillis: 5000,
		, minEvictableIdleTimeMillis: 60000
		...other stuff...
};

Last, has Lucee considered NOT using commons-pool for database connection pools? If you’re sticking to commons, commons-dbcp is probably more appropriate.

Don’t forget to tell us about your stack!

OS: Docker image 6.0.1.83
Java Version: Docker image 6.0.1.83
Tomcat Version: Docker image 6.0.1.83
Lucee Version: Docker image 6.0.1.83

1 Like

Having same issue in trying to upgrade from Lucee 5 to 6.1.0.243. Keep seeing increasing # of datasource connections and eventually Postgresql complains “remaining connections reserved for superuser”. Only a server restart resolves the issue (temporarily). Using a combo of Hibernate ORM and reqular SQL queries. @Joe_Rinehart Were you able to find any solution / workaround?

Sounds like: [LDEV-4339] - Lucee

1 Like