{"record":{"id":"95926d8e808d4036","repo":"apache/flink","slug":"no-tasks-finished-successfully","errorCode":null,"errorMessage":"No tasks finished successfully.","messagePattern":"No tasks finished successfully\\.","errorType":"exception","errorClass":"ExecutionException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/concurrent/DirectExecutorService.java","lineNumber":211,"sourceCode":"\n    @Override\n    @Nonnull\n    public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks)\n            throws ExecutionException {\n        throwRejectedExecutionExceptionIfShutdown();\n\n        Exception exception = null;\n\n        for (Callable<T> task : tasks) {\n            try {\n                return task.call();\n            } catch (Exception e) {\n                // try next task\n                exception = e;\n            }\n        }\n\n        throw new ExecutionException(\"No tasks finished successfully.\", exception);\n    }\n\n    @Override\n    public <T> T invokeAny(\n            @Nonnull Collection<? extends Callable<T>> tasks, long timeout, @Nonnull TimeUnit unit)\n            throws ExecutionException, TimeoutException {\n        throwRejectedExecutionExceptionIfShutdown();\n\n        long end = System.currentTimeMillis() + unit.toMillis(timeout);\n        Exception exception = null;\n\n        Iterator<? extends Callable<T>> iterator = tasks.iterator();\n\n        while (end > System.currentTimeMillis() && iterator.hasNext()) {\n            Callable<T> callable = iterator.next();\n\n            try {\n                return callable.call();","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/concurrent/DirectExecutorService.java#L193-L229","documentation":"DirectExecutorService.invokeAny executes callables one by one on the calling thread and returns the first success. If every callable throws, it wraps the LAST observed exception in an ExecutionException with this message. This mirrors the standard ExecutorService.invokeAny contract for the all-failed case.","triggerScenarios":"Calling invokeAny(tasks) where tasks is non-empty and every Callable.call() throws; the returned exception's cause is the final task's exception, earlier ones are lost.","commonSituations":"Failover/retry helpers that try a list of replicas or strategies with the direct executor; unit tests simulating all-backends-down; missing the fact that only the last cause is preserved when debugging.","solutions":["Inspect getCause() of the ExecutionException — it is the last task's exception, which is usually the most informative starting point.","Fix or make reachable at least one of the underlying resources/callables.","If you need all failure causes, replace invokeAny with per-task submit and collect exceptions yourself."],"exampleFix":"// before\ntry { service.invokeAny(tasks); } catch (ExecutionException e) { log.error(\"failed\"); }\n\n// after\ntry { service.invokeAny(tasks); }\ncatch (ExecutionException e) { log.error(\"all tasks failed, last cause:\", e.getCause()); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { T r = executor.invokeAny(tasks); }\ncatch (ExecutionException e) { Throwable root = e.getCause(); /* handle last task's failure */ }","preventionTips":["Remember invokeAny surfaces only the LAST failure cause.","Ensure at least one callable is expected to succeed; otherwise use submit+collect.","Log getCause(), not the wrapper, when diagnosing."],"tags":["concurrency","executor","invoke-any","failover"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}