{"record":{"id":"904a6a0b6ddcf151","repo":"apache/seatunnel","slug":"execute-given-execution-failed-after-retry-n-tim","errorCode":null,"errorMessage":"Execute given execution failed after retry <n> times","messagePattern":"Execute given execution failed after retry <n> times","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/RetryUtils.java","lineNumber":75,"sourceCode":"                    String attemptMessage =\n                            \"Failed to execute due to {}. Retrying attempt ({}/{}) after backoff of {} ms\";\n                    if (retryMaterial.getSleepTimeMillis() > 0) {\n                        long backoff = retryMaterial.computeRetryWaitTimeMillis(i);\n                        log.debug(\n                                attemptMessage,\n                                ExceptionUtils.getMessage(e),\n                                i,\n                                retryTimes,\n                                backoff);\n                        Thread.sleep(backoff);\n                    } else {\n                        log.info(attemptMessage, ExceptionUtils.getMessage(e), i, retryTimes, 0);\n                    }\n                }\n            }\n        } while (i < retryTimes);\n        if (retryMaterial.shouldThrowException()) {\n            throw new RuntimeException(\n                    \"Execute given execution failed after retry \" + retryTimes + \" times\",\n                    lastException);\n        }\n        return null;\n    }\n\n    public static class RetryMaterial {\n        /** An arbitrary absolute maximum practical retry time. */\n        public static final long MAX_RETRY_TIME_MS = TimeUnit.SECONDS.toMillis(20);\n\n        /** The maximum retry time. */\n        public static final long MAX_RETRY_TIME = 32;\n\n        /**\n         * Retry times, if you set it to 1, the given execution will be executed twice. Should be\n         * greater than 0.\n         */\n        private final int retryTimes;","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/RetryUtils.java#L57-L93","documentation":"After exhausting all retry attempts, retryWithException throws RuntimeException 'Execute given execution failed after retry <n> times' wrapping the lastException, but only when RetryMaterial.shouldThrowException() is true. If shouldThrowException is false, the method returns null instead of throwing. The message reports the configured retryTimes total, not the attempts actually consumed.","triggerScenarios":"The Execution<T, Exception> kept throwing a retryable exception on every attempt until i reached retryTimes, and retryMaterial.shouldThrowException() was true. Triggered by any persistent failure: network unreachable, endpoint down, serialization error on each try.","commonSituations":"HTTP/DB calls retried via RetryUtils that fail for a non-transient reason (bad credentials, wrong host) so all retries fail; retry interval too short for a recovering service; the wrapped lastException in the cause holds the real diagnosis.","solutions":["Inspect the cause chain (lastException) to fix the root failure — retries do not help non-transient errors","Increase retryTimes and/or retry interval/backoff in RetryMaterial if the failure is transient but needs more time","Adjust the retryCondition so non-retryable errors fail fast instead of consuming all attempts","Call with shouldThrowException=false and handle the null return if the caller prefers graceful degradation"],"exampleFix":"// before\nRetryMaterial.builder().retryTimes(3).retryInterval(Duration.ofMillis(100)).build();\n// after\nRetryMaterial.builder().retryTimes(10).retryInterval(Duration.ofSeconds(5)).build();","handlingStrategy":"retry","validationCode":"// Ensure attempts are worth retrying: check connectivity first\nboolean reachable = host != null && !host.isEmpty();\nif (!reachable) { throw new IllegalArgumentException(\"host required before retry\"); }","typeGuard":null,"tryCatchPattern":"try {\n  return RetryUtils.retryWithException(execution, material);\n} catch (RuntimeException e) {\n  log.error(\"All {} retries failed\", material.getRetryTimes(), e.getCause());\n  throw e.getCause() != null ? new RuntimeException(e.getCause()) : e;\n}","preventionTips":["Inspect lastException (cause) — retries never fix non-transient failures","Use exponential backoff/adequate retry intervals for recovering services","Configure retryCondition to stop early on non-retryable errors (e.g. auth failures)","Alert on repeated exhaustion rather than silently re-retrying"],"tags":["retry","timeout","transient-failure"],"backgroundTag":"request-timeout","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}