{"record":{"id":"a893fc2d3f9ace7d","repo":"SonarSource/sonarqube","slug":"pool-did-not-terminate","errorCode":null,"errorMessage":"Pool {} did not terminate","messagePattern":"Pool (.+?) did not terminate","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/sonar-server-common/src/main/java/org/sonar/server/util/AbstractStoppableExecutorService.java","lineNumber":54,"sourceCode":"public abstract class AbstractStoppableExecutorService<D extends ExecutorService> implements StoppableExecutorService {\n  protected final D delegate;\n\n  public AbstractStoppableExecutorService(D delegate) {\n    this.delegate = delegate;\n  }\n\n  @Override\n  public void stop() {\n    // Disable new tasks from being submitted\n    delegate.shutdown();\n    try {\n      // Wait a while for existing tasks to terminate\n      if (!delegate.awaitTermination(5, TimeUnit.SECONDS)) {\n        // Cancel currently executing tasks\n        delegate.shutdownNow();\n        // Wait a while for tasks to respond to being canceled\n        if (!delegate.awaitTermination(5, TimeUnit.SECONDS)) {\n          LoggerFactory.getLogger(getClass()).warn(\"Pool {} did not terminate\", getClass().getSimpleName());\n        }\n      }\n    } catch (InterruptedException ie) {\n      LoggerFactory.getLogger(getClass()).warn(\"Termination of pool {} failed\", getClass().getSimpleName(), ie);\n      // (Re-)Cancel if current thread also interrupted\n      delegate.shutdownNow();\n    }\n  }\n\n  @Override\n  public void shutdown() {\n    delegate.shutdown();\n  }\n\n  @Override\n  public List<Runnable> shutdownNow() {\n    return delegate.shutdownNow();\n  }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-server-common/src/main/java/org/sonar/server/util/AbstractStoppableExecutorService.java#L36-L72","documentation":"AbstractStoppableExecutorService.stop performs an orderly shutdown, waits 5s, calls shutdownNow, and waits another 5s; if the pool still has not terminated it logs this warning. It means some tasks ignored interruption and are still running while the component is being stopped — possible resource leaks or delayed shutdown.","triggerScenarios":"stop() is called during server/component shutdown while a submitted Runnable/Callable ignores interrupts (long loop without interrupt checks) or blocks on non-interruptible I/O, so both awaitTermination(5s) calls return false.","commonSituations":"Blocking network/DB calls without timeout in worker tasks; infinite processing loops in tasks; many queued tasks that cannot finish within the grace period; shutdown during heavy load.","solutions":["Make worker tasks responsive to interruption: check Thread.currentThread().isInterrupted() and honor InterruptedException","Add timeouts to blocking calls (HTTP client timeouts, socket timeouts, DB query timeouts)","Check for non-daemon long-running tasks submitted to this pool and bound their work","If it is a stuck third-party call, isolate it in a separate executor or use futures with get(timeout)"],"exampleFix":"// before\nwhile (true) { process(next()); }\n// after\nwhile (!Thread.currentThread().isInterrupted()) {\n  process(next());\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  pool.shutdown();\n  if (!pool.awaitTermination(5, TimeUnit.SECONDS)) {\n    pool.shutdownNow();\n    if (!pool.awaitTermination(5, TimeUnit.SECONDS)) {\n      log.warn(\"Pool {} did not terminate; tasks may be stuck\", name);\n    }\n  }\n} catch (InterruptedException ie) {\n  pool.shutdownNow();\n  Thread.currentThread().interrupt();\n}","preventionTips":["Write tasks that check Thread.currentThread().isInterrupted() regularly","Set timeouts on all blocking I/O performed inside pooled tasks","Avoid submitting unbounded long-running loops to stoppable executors"],"tags":["threading","executor","shutdown","sonarqube"],"backgroundTag":"executor-shutdown-timeout","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}