apache/seatunnel · error · IOException

Close ErrorHandler for transform stage failed

Error message

Close ErrorHandler for transform stage failed

What it means

TransformFlowLifeCycle.close() closes the transform stage's ErrorHandler (error-data sink handler). If errorHandler.close() throws, the IOException is logged and rethrown wrapped with this message, failing the task's close/cleanup phase.

Solutions

  1. Check the wrapped cause 'e' for the real error from the error sink (connectivity, permissions, disk).
  2. Verify the error-collection sink configured for the transform is reachable and writable at job end.
  3. Ensure the error sink is not closed earlier by another component (double-close).
  4. Retry the job; if transient network errors persist, add retries/timeout tuning to the error sink.

Example fix

// before: swallow close errors into task failure
// after: log and continue close to avoid masking primary failure
try {
    errorHandler.close();
} catch (Exception e) {
    log.warn("Close ErrorHandler for transform stage failed", e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try { errorHandler.close(); } catch (Exception e) { log.warn("error sink close failed", e); /* do not mask the primary close error */ }

Prevention

When it happens

Trigger: close() invoked during task teardown while the underlying ErrorHandler close (e.g. flushing/closing the error sink writer or its network/client resources) throws any Exception.

Common situations: Error-output sink (file/DB/HTTP) is unreachable or already closed; disk full or permission problem writing residual error data; external error-sink connection broken mid-job.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/flow/TransformFlowLifeCycle.java:370

    @Override
    public void close() throws IOException {
        for (SeaTunnelTransform<T> t : transform) {
            try {
                t.close();
            } catch (Exception e) {
                log.error(
                        "Close transform: {} failed, cause: {}",
                        t.getPluginName(),
                        e.getMessage(),
                        e);
            }
        }
        if (errorHandler != null) {
            try {
                errorHandler.close();
            } catch (Exception e) {
                log.error("Close ErrorHandler for transform stage failed", e);
                throw new IOException("Close ErrorHandler for transform stage failed", e);
            }
        }
        super.close();
    }

    private void flushErrorHandler() {
        flushErrorHandler(null);
    }

    private void flushErrorHandler(Long checkpointId) {
        if (errorHandler == null) {
            return;
        }
        try {
            if (checkpointId == null) {
                errorHandler.flush();
            } else {
                errorHandler.flush(checkpointId);

View on GitHub (pinned to cf67b549a7)