{"record":{"id":"d9e388475537a569","repo":"apache/cassandra","slug":"timeout-task-did-not-finish-in-timeout","errorCode":null,"errorMessage":"Timeout - task did not finish in ${timeout}","messagePattern":"Timeout - task did not finish in (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/FBUtilities.java","lineNumber":596,"sourceCode":"    public static <T> T waitOnFuture(Future<T> future, Duration timeout)\n    {\n        Preconditions.checkArgument(!timeout.isNegative(), \"Timeout must not be negative, provided %s\", timeout);\n        try\n        {\n            return future.get(timeout.toNanos(), TimeUnit.NANOSECONDS);\n        }\n        catch (ExecutionException ee)\n        {\n            logger.info(\"Exception occurred in async code\", ee);\n            throw Throwables.cleaned(ee);\n        }\n        catch (InterruptedException ie)\n        {\n            throw new AssertionError(ie);\n        }\n        catch (TimeoutException e)\n        {\n            throw new RuntimeException(\"Timeout - task did not finish in \" + timeout);\n        }\n    }\n\n    public static <T, F extends Future<? extends T>> F waitOnFirstFuture(Iterable<? extends F> futures)\n    {\n        return waitOnFirstFuture(futures, 100);\n    }\n    /**\n     * Only wait for the first future to finish from a list of futures. Will block until at least 1 future finishes.\n     * @param futures The futures to wait on\n     * @return future that completed.\n     */\n    public static <T, F extends Future<? extends T>> F waitOnFirstFuture(Iterable<? extends F> futures, long delay)\n    {\n        while (true)\n        {\n            Iterator<? extends F> iter = futures.iterator();\n            if (!iter.hasNext())","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/FBUtilities.java#L578-L614","documentation":"FBUtilities.waitOnFuture blocks on an Awaitable/Future with a caller-supplied timeout. If the task does not complete within `timeout` units, the TimeoutException is rethrown as a plain RuntimeException with a message naming the timeout. It signals that an internal async task (e.g. schema pull,bootstrap step) exceeded its deadline.","triggerScenarios":"Calling FBUtilities.waitOnFuture(future, timeout) where the future's computation is still pending when the deadline expires; e.g. waiting on schema agreement, REMOTE tasks via StageManager, or Verbs-based one-shot tasks whose peer is slow or dead.","commonSituations":"A target node is overloaded, GC-paused, down, or network-partitioned so the awaited remote task never returns; timeout configured too aggressively; bootstrap/repair hanging on a large operation.","solutions":["Check the awaited node is alive and responsive (nodetool status, logs); restart or replace it","Increase the timeout argument at the call site if the operation is legitimately slow","Inspect why the underlying task hangs (thread dumps, tracing) and fix the root cause","Retry the operation once the remote node recovers"],"exampleFix":"// before\nFBUtilities.waitOnFuture(future, 5, TimeUnit.SECONDS);\n// after\nFBUtilities.waitOnFuture(future, 60, TimeUnit.SECONDS); // allow slow large task to finish","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    FBUtilities.waitOnFuture(future, timeout, TimeUnit.SECONDS);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Timeout - task did not finish\")) {\n        // inspect peer health, retry with larger timeout or fail the operation\n    } else throw e;\n}","preventionTips":["Set timeouts proportional to the expected worst-case operation size","Monitor peer node health/GC pauses before issuing remote waits","Add logging around long-running awaited tasks","Handle timeout distinctly from other RuntimeExceptions"],"tags":["timeout","future","async"],"backgroundTag":"request-timeout","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}