apache/seatunnel · error · RuntimeException
Failed to close error sink writer
Error message
Failed to close error sink writer
What it means
Thrown by DefaultErrorSinkWriter.closeWriterIfPossible when the wrapped error-sink writer's close() fails. The error sink writer is a secondary writer that receives rows rejected by row-level error handling; failure to close it usually means the underlying sink (e.g. a file or JDBC target) could not flush or release resources. The original writer reference is still cleared in the finally block, so a subsequent attempt cannot retry the close.
Solutions
- Inspect the wrapped cause exception to find the real sink failure (disk, network, permissions).
- Fix the underlying sink resource (free disk space, restore connectivity) and restart the job.
- Verify the error-sink plugin is correctly configured and reachable before enabling ROUTE mode.
- If transient, retry the job; buffered error records may be lost if the sink never flushed.
Example fix
// before: sink.close() fails due to unwritten buffered data on a full disk
// after: pre-check writable space / wrap close with cause logging
try {
sinkWriter.close();
} catch (Exception e) {
LOG.error("error sink close failed; cause:", e.getCause());
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
if (diskFree(errorSinkPath) < requiredBytes) { failFast("insufficient space for error sink"); } Try / catch
try { errorHandler.close(); } catch (RuntimeException e) { log.error("error sink close failed", e.getCause()); } Prevention
- Ensure the error-sink target has free space and connectivity for the job's duration
- Choose a reliable error-sink plugin (e.g. Console for tests, JDBC/File with retries for prod)
- Monitor sink health before job shutdown windows
When it happens
Trigger: Calling close() or ensureInitialized() on DefaultErrorSinkWriter while the underlying sink writer's close() throws — e.g. disk full while flushing buffered records, network drop to the error-sink target, or a sink plugin that fails cleanup.
Common situations: Error-sink writing to a local file on a full disk; error-sink database connection lost mid-job; job shutdown racing with sink flush failures.
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
- Failed to close error sink writer
- CLOSE_CLIENT_FAILED
- CLOSE_CQL_SESSION_FAILED
- Close Hudi record writer failed.
- Closing httpClient failed.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/230c2b72e3662580.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/DefaultErrorSinkWriter.java:676
}
if (failure instanceof Error) {
throw (Error) failure;
}
if (failure instanceof Exception) {
throw (Exception) failure;
}
throw new RuntimeException(failure);
}
private void closeWriterIfPossible() {
SinkWriter<SeaTunnelRow, ?, ?> sinkWriter = this.writer;
if (sinkWriter == null) {
return;
}
try {
sinkWriter.close();
} catch (Exception e) {
throw new RuntimeException("Failed to close error sink writer", e);
} finally {
this.writer = null;
}
}
private void releaseErrorSinkClassLoaderIfNeeded() {
if (classLoaderReleased) {
return;
}
List<URL> jars = this.errorSinkPluginJars;
if (jars == null || jars.isEmpty()) {
classLoaderReleased = true;
return;
}
try {
classLoaderService.releaseClassLoader(jobId, jars);
} catch (Throwable e) {
if (e instanceof Error) {View on GitHub (pinned to cf67b549a7)