apache/seatunnel · error · RuntimeException

Failed to close error sink writer

Error message

Failed to close error sink writer

What it means

ErrorHandler.close wraps errorSinkWriter.close(); if it throws a checked Exception it is rewrapped in a RuntimeException with this message. It mirrors DefaultErrorSinkWriter's own close failure and indicates the error sink could not flush/release its resources during job shutdown.

Solutions

  1. Read the cause chain on the RuntimeException to identify the sink-level failure.
  2. Ensure the error-sink target is writable/available for the whole job lifetime, including shutdown.
  3. Fix underlying resource issues (disk, network, permissions) before rerunning.
  4. If both the job error and this close error appear, fix the primary job error first — it often cascades.

Example fix

// before: close fails silently cascading to RuntimeException
// after: ensure writer flushed before close
errorSinkWriter.prepareCommit();
errorSinkWriter.close();
Defensive patterns

Strategy: try-catch

Try / catch

try { errorHandler.close(); } catch (RuntimeException e) { log.error("ErrorHandler close failed, cause:", e.getCause()); }

Prevention

When it happens

Trigger: Calling ErrorHandler.close() at job/task teardown while the error-sink writer's close() throws a checked exception (I/O failure on flush, connection teardown error).

Common situations: Job cancelled while error sink still buffering; error-sink file system or DB unavailable at shutdown; plugin close() with side-effectful cleanup that fails after earlier write errors.

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/9e01282881b5a9a9. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/ErrorHandler.java:288

    }

    @Override
    public void close() {
        if (config.getMode() != ErrorHandlerMode.DISABLE) {
            log.info(
                    "ErrorHandler summary: mode={}, totalRecords={}, errorRecords={}, errorSinkEnabled={}",
                    config.getMode(),
                    counter.getTotalRecords(),
                    counter.getErrorRecords(),
                    errorSinkWriter != null);
        }
        if (errorSinkWriter != null) {
            try {
                errorSinkWriter.close();
            } catch (RuntimeException e) {
                throw e;
            } catch (Exception e) {
                throw new RuntimeException("Failed to close error sink writer", e);
            }
        }
    }
}

View on GitHub (pinned to cf67b549a7)