{"record":{"id":"8fc27b07fe3e4157","repo":"apache/druid","slug":"cleaning-up-idle-connections-is-a-bad-idea-if-yo","errorCode":null,"errorMessage":"Cleaning up idle connections is a bad idea.  If your services can't handle the max number then lower the max number.","messagePattern":"Cleaning up idle connections is a bad idea\\.  If your services can't handle the max number then lower the max number\\.","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/http/client/pool/ResourcePoolConfig.java","lineNumber":48,"sourceCode":"      int maxPerKey,\n      long unusedConnectionTimeoutMillis\n  )\n  {\n    this.maxPerKey = maxPerKey;\n    this.unusedConnectionTimeoutMillis = unusedConnectionTimeoutMillis;\n  }\n\n  @Deprecated\n  public ResourcePoolConfig(\n      int maxPerKey,\n      boolean cleanIdle,\n      long unusedConnectionTimeoutMillis\n  )\n  {\n    this(maxPerKey, unusedConnectionTimeoutMillis);\n\n    if (cleanIdle) {\n      throw new IllegalStateException(\n          \"Cleaning up idle connections is a bad idea.  \"\n          + \"If your services can't handle the max number then lower the max number.\"\n      );\n    }\n  }\n\n  public int getMaxPerKey()\n  {\n    return maxPerKey;\n  }\n\n  public long getUnusedConnectionTimeoutMillis()\n  {\n    return unusedConnectionTimeoutMillis;\n  }\n}\n","sourceCodeStart":30,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/http/client/pool/ResourcePoolConfig.java#L30-L65","documentation":"ResourcePoolConfig's constructor with the cleanIdle flag deliberately refuses to build a connection pool configured to clean up idle connections. The Druid HTTP client authors consider idle-connection eviction harmful (it defeats connection reuse and hides capacity problems), so enabling it is a hard programming error, thrown immediately at config construction time.","triggerScenarios":"Calling the deprecated 3-arg ResourcePoolConfig constructor (maxPerKey, unusedConnectionTimeoutMillis, cleanIdle) with cleanIdle=true.","commonSituations":"Copying old example code that used the third boolean argument; attempting to mitigate pool exhaustion by evicting idle connections; migrating code from an older Druid HTTP client version where the flag existed.","solutions":["Pass cleanIdle=false, or better, use the 2-arg constructor ResourcePoolConfig(maxPerKey, unusedConnectionTimeoutMillis)","If the pool cannot handle the load, lower the configured maxPerKey value or increase service capacity instead of enabling idle cleanup","Refactor callers so they no longer construct this deprecated overload"],"exampleFix":"// before\nnew ResourcePoolConfig(10, 60000, true);\n// after\nnew ResourcePoolConfig(10, 60000);","handlingStrategy":"validation","validationCode":"if (useCleanIdleFlagOverload) {\n  throw new IllegalArgumentException(\"cleanIdle is unsupported; use ResourcePoolConfig(maxPerKey, unusedConnectionTimeoutMillis)\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  config = new ResourcePoolConfig(maxPerKey, timeout, cleanIdle);\n} catch (IllegalStateException e) {\n  config = new ResourcePoolConfig(maxPerKey, timeout);\n  LOG.warn(e, \"cleanIdle unsupported; fell back to 2-arg config\");\n}","preventionTips":["Always use the 2-arg ResourcePoolConfig constructor","Treat idle-connection eviction as an anti-pattern; size maxPerKey to real load","Grep your codebase for 'cleanIdle' usage during upgrades"],"tags":["http-client","connection-pool","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}