alibaba/druid · error · IllegalArgumentException
illegal initialSize {}, maxActive {}
Error message
illegal initialSize {}, maxActive {} What it means
IllegalArgumentException thrown during init() when getInitialSize() > maxActive. initialSize controls how many connections are created eagerly at startup; creating more than the pool's maximum would immediately overflow the pool, so Druid rejects the combination.
Source
Thrown at core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java:727
cacheServerConfigurationSet = true;
} else if (this.jdbcUrl.indexOf("cacheServerConfiguration") != -1) {
cacheServerConfigurationSet = true;
}
if (cacheServerConfigurationSet) {
this.connectProperties.put("cacheServerConfiguration", "true");
}
}
if (maxActive <= 0) {
throw new IllegalArgumentException("illegal maxActive " + maxActive);
}
if (maxActive < minIdle) {
throw new IllegalArgumentException("illegal maxActive " + maxActive);
}
if (getInitialSize() > maxActive) {
throw new IllegalArgumentException("illegal initialSize " + this.initialSize + ", maxActive " + maxActive);
}
if (timeBetweenLogStatsMillis > 0 && useGlobalDataSourceStat) {
throw new IllegalArgumentException("timeBetweenLogStatsMillis not support useGlobalDataSourceStat=true");
}
if (maxEvictableIdleTimeMillis < minEvictableIdleTimeMillis) {
throw new SQLException("maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis");
}
if (keepAlive && keepAliveBetweenTimeMillis <= timeBetweenEvictionRunsMillis) {
throw new SQLException("keepAliveBetweenTimeMillis must be greater than timeBetweenEvictionRunsMillis");
}
if (this.driverClass != null) {
this.driverClass = driverClass.trim();
}
View on GitHub (pinned to fa8dc99126)
Solutions
- Set initialSize <= maxActive.
- For warm-up, scale both initialSize and maxActive up together (e.g. initialSize=5, maxActive=20).
- Leave initialSize at default (or 0) if you do not need eager warm-up.
Example fix
# before druid.initialSize=10 druid.maxActive=5 # after druid.initialSize=5 druid.maxActive=20
Defensive patterns
Strategy: validation
Validate before calling
if (dataSource.getInitialSize() > dataSource.getMaxActive()) {
throw new IllegalStateException("initialSize (" + dataSource.getInitialSize()
+ ") must be <= maxActive (" + dataSource.getMaxActive() + ")");
} Prevention
- Scale initialSize with maxActive when configuring warm-up.
- Leave initialSize small/default unless eager warm-up is required.
- Validate the trio (maxActive, minIdle, initialSize) together.
When it happens
Trigger: init() runs with this.initialSize > maxActive. The check at line 726 throws, reporting both values.
Common situations: initialSize set high for fast warm-up while maxActive left small; default initialSize larger than an intentionally tiny maxActive; config drift between environments.
Related errors
- illegal maxActive {}
- maxActive less than minIdle, {} < {}
- maxActive can't not set zero
- timeBetweenLogStatsMillis not support useGlobalDataSourceSta
- maxEvictableIdleTimeMillis must be grater than minEvictableI
AI-assisted analysis of alibaba/druid@fa8dc99126 (2026-08-14).
Data as JSON: /api/errors/75163dd739e5ad9c.
Report an issue: GitHub.