{"record":{"id":"bc60dc15805dd9b8","repo":"alibaba/druid","slug":"maxevictableidletimemillis-must-be-grater-than-min","errorCode":null,"errorMessage":"maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis","messagePattern":"maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"core/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java","lineNumber":821,"sourceCode":"\n    public void setKeepAliveBetweenTimeMillis(long keepAliveBetweenTimeMillis) {\n        if (keepAliveBetweenTimeMillis < 1000 * 30) {\n            LOG.error(\"keepAliveBetweenTimeMillis should be greater than 30000\");\n        }\n        this.keepAliveBetweenTimeMillis = keepAliveBetweenTimeMillis;\n    }\n\n    public long getMaxEvictableIdleTimeMillis() {\n        return maxEvictableIdleTimeMillis;\n    }\n\n    public void setMaxEvictableIdleTimeMillis(long maxEvictableIdleTimeMillis) {\n        if (maxEvictableIdleTimeMillis < 1000 * 30) {\n            LOG.error(\"maxEvictableIdleTimeMillis should be greater than 30000\");\n        }\n\n        if (inited && maxEvictableIdleTimeMillis < minEvictableIdleTimeMillis) {\n            throw new IllegalArgumentException(\"maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis\");\n        }\n\n        this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis;\n    }\n\n    public long getPhyTimeoutMillis() {\n        return phyTimeoutMillis;\n    }\n\n    public void setPhyTimeoutMillis(long phyTimeoutMillis) {\n        this.phyTimeoutMillis = phyTimeoutMillis;\n    }\n\n    public long getPhyMaxUseCount() {\n        return phyMaxUseCount;\n    }\n\n    public void setPhyMaxUseCount(long phyMaxUseCount) {","sourceCodeStart":803,"sourceCodeEnd":839,"githubUrl":"https://github.com/alibaba/druid/blob/fa8dc9912637a2f729eef9f55356621fec18d40e/core/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java#L803-L839","documentation":"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.","triggerScenarios":"After DruidDataSource.init() has run, calling setMaxEvictableIdleTimeMillis(value) with value < current getMinEvictableIdleTimeMillis().","commonSituations":"Runtime reconfiguration (e.g. Spring Cloud Config refresh) that lowers maxEvictableIdleTimeMillis below minEvictableIdleTimeMillis; setting eviction intervals in the wrong order after init.","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."],"exampleFix":"// before (runtime, after init)\n// ds.setMaxEvictableIdleTimeMillis(10_000); // min is 60_000 -> throws\n\n// after\n// ds.setMinEvictableIdleTimeMillis(5_000);\n// ds.setMaxEvictableIdleTimeMillis(10_000);","handlingStrategy":"validation","validationCode":"long max = newMaxEvictable;\nif (ds.isInited() && max < ds.getMinEvictableIdleTimeMillis()) {\n    throw new IllegalStateException(\"maxEvictable \" + max + \" < minEvictable \" + ds.getMinEvictableIdleTimeMillis());\n}\nds.setMaxEvictableIdleTimeMillis(max);","typeGuard":null,"tryCatchPattern":"try {\n    ds.setMaxEvictableIdleTimeMillis(value);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"grater than minEvictableIdleTimeMillis\")) {\n        // raise min first, or pick max >= min\n    }\n    throw e;\n}","preventionTips":["Always keep maxEvictableIdleTimeMillis >= minEvictableIdleTimeMillis (and >= 30000ms).","When reconfiguring at runtime, adjust min before max if lowering.","Set eviction timing before init() where possible."],"tags":["datasource","eviction","validation","configuration"],"backgroundTag":null,"analyzedSha":"fa8dc9912637a2f729eef9f55356621fec18d40e","analyzedAt":"2026-08-14T04:55:06.789Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}