{"record":{"id":"230c2b72e3662580","repo":"apache/seatunnel","slug":"failed-to-close-error-sink-writer","errorCode":null,"errorMessage":"Failed to close error sink writer","messagePattern":"Failed to close error sink writer","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/DefaultErrorSinkWriter.java","lineNumber":676,"sourceCode":"        }\n        if (failure instanceof Error) {\n            throw (Error) failure;\n        }\n        if (failure instanceof Exception) {\n            throw (Exception) failure;\n        }\n        throw new RuntimeException(failure);\n    }\n\n    private void closeWriterIfPossible() {\n        SinkWriter<SeaTunnelRow, ?, ?> sinkWriter = this.writer;\n        if (sinkWriter == null) {\n            return;\n        }\n        try {\n            sinkWriter.close();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Failed to close error sink writer\", e);\n        } finally {\n            this.writer = null;\n        }\n    }\n\n    private void releaseErrorSinkClassLoaderIfNeeded() {\n        if (classLoaderReleased) {\n            return;\n        }\n        List<URL> jars = this.errorSinkPluginJars;\n        if (jars == null || jars.isEmpty()) {\n            classLoaderReleased = true;\n            return;\n        }\n        try {\n            classLoaderService.releaseClassLoader(jobId, jars);\n        } catch (Throwable e) {\n            if (e instanceof Error) {","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/DefaultErrorSinkWriter.java#L658-L694","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: sink.close() fails due to unwritten buffered data on a full disk\n// after: pre-check writable space / wrap close with cause logging\ntry {\n    sinkWriter.close();\n} catch (Exception e) {\n    LOG.error(\"error sink close failed; cause:\", e.getCause());\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (diskFree(errorSinkPath) < requiredBytes) { failFast(\"insufficient space for error sink\"); }","typeGuard":null,"tryCatchPattern":"try { errorHandler.close(); } catch (RuntimeException e) { log.error(\"error sink close failed\", e.getCause()); }","preventionTips":["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"],"tags":["error-sink","resource-cleanup","close-failed"],"backgroundTag":"file-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}