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
- Read the cause chain on the RuntimeException to identify the sink-level failure.
- Ensure the error-sink target is writable/available for the whole job lifetime, including shutdown.
- Fix underlying resource issues (disk, network, permissions) before rerunning.
- 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
- Keep the error-sink target available through job teardown
- Avoid cancelling jobs while error sink has pending writes
- Investigate the cause chain, not just the wrapper message
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
- Error sink is closing for stage
- Error sink worker thread is still alive after close…
- Failed to close error sink writer
- Failed to invoke . ()
- Both channel and connection closing failed. Logging channel…
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)