apache/seatunnel · error · RuntimeException

Execute given execution failed after retry <n> times

Error message

Execute given execution failed after retry <n> times

What it means

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.

Source

Thrown at seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/RetryUtils.java:75

                    String attemptMessage =
                            "Failed to execute due to {}. Retrying attempt ({}/{}) after backoff of {} ms";
                    if (retryMaterial.getSleepTimeMillis() > 0) {
                        long backoff = retryMaterial.computeRetryWaitTimeMillis(i);
                        log.debug(
                                attemptMessage,
                                ExceptionUtils.getMessage(e),
                                i,
                                retryTimes,
                                backoff);
                        Thread.sleep(backoff);
                    } else {
                        log.info(attemptMessage, ExceptionUtils.getMessage(e), i, retryTimes, 0);
                    }
                }
            }
        } while (i < retryTimes);
        if (retryMaterial.shouldThrowException()) {
            throw new RuntimeException(
                    "Execute given execution failed after retry " + retryTimes + " times",
                    lastException);
        }
        return null;
    }

    public static class RetryMaterial {
        /** An arbitrary absolute maximum practical retry time. */
        public static final long MAX_RETRY_TIME_MS = TimeUnit.SECONDS.toMillis(20);

        /** The maximum retry time. */
        public static final long MAX_RETRY_TIME = 32;

        /**
         * Retry times, if you set it to 1, the given execution will be executed twice. Should be
         * greater than 0.
         */
        private final int retryTimes;

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect the cause chain (lastException) to fix the root failure — retries do not help non-transient errors
  2. Increase retryTimes and/or retry interval/backoff in RetryMaterial if the failure is transient but needs more time
  3. Adjust the retryCondition so non-retryable errors fail fast instead of consuming all attempts
  4. Call with shouldThrowException=false and handle the null return if the caller prefers graceful degradation

Example fix

// before
RetryMaterial.builder().retryTimes(3).retryInterval(Duration.ofMillis(100)).build();
// after
RetryMaterial.builder().retryTimes(10).retryInterval(Duration.ofSeconds(5)).build();
Defensive patterns

Strategy: retry

Validate before calling

// Ensure attempts are worth retrying: check connectivity first
boolean reachable = host != null && !host.isEmpty();
if (!reachable) { throw new IllegalArgumentException("host required before retry"); }

Try / catch

try {
  return RetryUtils.retryWithException(execution, material);
} catch (RuntimeException e) {
  log.error("All {} retries failed", material.getRetryTimes(), e.getCause());
  throw e.getCause() != null ? new RuntimeException(e.getCause()) : e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/904a6a0b6ddcf151. Report an issue: GitHub.