{"record":{"id":"aa3855f5157c0339","repo":"apache/cassandra","slug":"executor-name-not-terminated","errorCode":null,"errorMessage":"${executor.name} not terminated","messagePattern":"(.+?) not terminated","errorType":"exception","errorClass":"TimeoutException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/concurrent/SharedExecutorPool.java","lineNumber":163,"sourceCode":"        SEPExecutor executor = new SEPExecutor(this, maxConcurrency, maximumPoolSizeListener, jmxPath, name);\n        executors.add(executor);\n        return executor;\n    }\n\n    public synchronized void shutdownAndWait(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException\n    {\n        shuttingDown = true;\n        for (SEPExecutor executor : executors)\n            executor.shutdownNow();\n\n        terminateWorkers();\n\n        long until = nanoTime() + unit.toNanos(timeout);\n        for (SEPExecutor executor : executors)\n        {\n            executor.shutdown.await(until - nanoTime(), TimeUnit.NANOSECONDS);\n            if (!executor.isTerminated())\n                throw new TimeoutException(executor.name + \" not terminated\");\n        }\n    }\n\n    void terminateWorkers()\n    {\n        assert shuttingDown;\n\n        // To terminate our workers, we only need to unpark thread to make it runnable again,\n        // so that the pool.shuttingDown boolean is checked. If work was already in the process\n        // of being scheduled, worker will terminate upon running the task.\n        Map.Entry<Long, SEPWorker> e;\n        while (null != (e = descheduled.pollFirstEntry()))\n            e.getValue().assign(Work.SPINNING, false);\n\n        while (null != (e = spinning.pollFirstEntry()))\n            LockSupport.unpark(e.getValue().thread);\n    }\n}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/concurrent/SharedExecutorPool.java#L145-L181","documentation":"SharedExecutorPool.shutdownAndWait waits up to the given timeout for each SEPExecutor to terminate after shutdown; if an executor still has live workers when the deadline expires, it throws TimeoutException naming the executor. Called from test cleanup (e.g. testLocalStatePropagation), it means workers did not finish draining within the allotted time.","triggerScenarios":"Calling shutdownAndWait(timeout) (directly or via test-cluster teardown) while SEP executors still have queued tasks or workers blocked on something (I/O, a missing signal, a leaked task refusing to finish) past the timeout.","commonSituations":"dtest/JVM-test teardown hanging because a test left long-running or blocked tasks on an executor; timeouts set too short for the pending work; a worker stuck waiting on a promise/future never completed by the test.","solutions":["Ensure all tasks submitted to the executor complete or are cancelled before shutdownAndWait; drain pending work in test teardown","Check for workers blocked on external resources (network, locks, incomplete futures) and unblock them before shutdown","Increase the shutdown timeout to cover realistically slow teardown","If a task is genuinely stuck, this indicates a bug — take a thread dump to find the blocked worker and fix the underlying wait"],"exampleFix":"// before\nsharedPool.shutdownAndWait(1, TimeUnit.SECONDS); // TimeoutException: ... not terminated\n// after\nsharedPool.shutdownAndWait(30, TimeUnit.SECONDS); // allow workers to drain","handlingStrategy":"try-catch","validationCode":"if (!executor.isTerminated())\n    logger.warn(\"executor still running tasks before shutdownAndWait\");","typeGuard":null,"tryCatchPattern":"try\n{\n    sharedPool.shutdownAndWait(30, TimeUnit.SECONDS);\n}\ncatch (TimeoutException e)\n{\n    logger.error(\"Executor did not terminate: \" + e.getMessage());\n    // take thread dump / force cleanup\n}","preventionTips":["Complete or cancel all pending tasks before teardown","Unblock workers waiting on test-created futures/promises","Use generous shutdown timeouts in test cleanup","Investigate stuck workers with thread dumps rather than ignoring timeouts"],"tags":["timeout","executor","shutdown"],"backgroundTag":"request-timeout","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}