alibaba/druid · warning · IllegalArgumentException
maxEvictableIdleTimeMillis must be grater than minEvictableI
Error message
maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis
What it means
setMaxEvictableIdleTimeMillis enforces that, once the pool is initialized, maxEvictableIdleTimeMillis must not be set below the current minEvictableIdleTimeMillis. The guard runs only when inited==true; before init, an out-of-range value is merely logged ('should be greater than 30000'). Note the typo 'grater' in the message is upstream and benign.
Source
Thrown at core/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java:821
public void setKeepAliveBetweenTimeMillis(long keepAliveBetweenTimeMillis) {
if (keepAliveBetweenTimeMillis < 1000 * 30) {
LOG.error("keepAliveBetweenTimeMillis should be greater than 30000");
}
this.keepAliveBetweenTimeMillis = keepAliveBetweenTimeMillis;
}
public long getMaxEvictableIdleTimeMillis() {
return maxEvictableIdleTimeMillis;
}
public void setMaxEvictableIdleTimeMillis(long maxEvictableIdleTimeMillis) {
if (maxEvictableIdleTimeMillis < 1000 * 30) {
LOG.error("maxEvictableIdleTimeMillis should be greater than 30000");
}
if (inited && maxEvictableIdleTimeMillis < minEvictableIdleTimeMillis) {
throw new IllegalArgumentException("maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis");
}
this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis;
}
public long getPhyTimeoutMillis() {
return phyTimeoutMillis;
}
public void setPhyTimeoutMillis(long phyTimeoutMillis) {
this.phyTimeoutMillis = phyTimeoutMillis;
}
public long getPhyMaxUseCount() {
return phyMaxUseCount;
}
public void setPhyMaxUseCount(long phyMaxUseCount) {View on GitHub (pinned to fa8dc99126)
Solutions
- Set maxEvictableIdleTimeMillis >= minEvictableIdleTimeMillis (and both >= 30000ms as recommended).
- When reconfiguring at runtime, raise minEvictableIdleTimeMillis first or lower maxEvictableIdleTimeMillis only to a value still above min.
- Prefer configuring these before init() so only the advisory log applies.
Example fix
// before (runtime, after init) // ds.setMaxEvictableIdleTimeMillis(10_000); // min is 60_000 -> throws // after // ds.setMinEvictableIdleTimeMillis(5_000); // ds.setMaxEvictableIdleTimeMillis(10_000);
Defensive patterns
Strategy: validation
Validate before calling
long max = newMaxEvictable;
if (ds.isInited() && max < ds.getMinEvictableIdleTimeMillis()) {
throw new IllegalStateException("maxEvictable " + max + " < minEvictable " + ds.getMinEvictableIdleTimeMillis());
}
ds.setMaxEvictableIdleTimeMillis(max); Try / catch
try {
ds.setMaxEvictableIdleTimeMillis(value);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("grater than minEvictableIdleTimeMillis")) {
// raise min first, or pick max >= min
}
throw e;
} Prevention
- Always keep maxEvictableIdleTimeMillis >= minEvictableIdleTimeMillis (and >= 30000ms).
- When reconfiguring at runtime, adjust min before max if lowering.
- Set eviction timing before init() where possible.
When it happens
Trigger: After DruidDataSource.init() has run, calling setMaxEvictableIdleTimeMillis(value) with value < current getMinEvictableIdleTimeMillis().
Common situations: Runtime reconfiguration (e.g. Spring Cloud Config refresh) that lowers maxEvictableIdleTimeMillis below minEvictableIdleTimeMillis; setting eviction intervals in the wrong order after init.
Related errors
- timeBetweenEvictionRunsMillis must > 0
- minIdle greater than maxActive, {} must >= {}
- driverClassName length > 256.
- ConfigLoader only support DruidDataSource
- Config DataSource error.
AI-assisted analysis of alibaba/druid@fa8dc99126 (2026-08-14).
Data as JSON: /api/errors/bc60dc15805dd9b8.
Report an issue: GitHub.