{"record":{"id":"9e01282881b5a9a9","repo":"apache/seatunnel","slug":"failed-to-close-error-sink-writer-9e0128","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/ErrorHandler.java","lineNumber":288,"sourceCode":"    }\n\n    @Override\n    public void close() {\n        if (config.getMode() != ErrorHandlerMode.DISABLE) {\n            log.info(\n                    \"ErrorHandler summary: mode={}, totalRecords={}, errorRecords={}, errorSinkEnabled={}\",\n                    config.getMode(),\n                    counter.getTotalRecords(),\n                    counter.getErrorRecords(),\n                    errorSinkWriter != null);\n        }\n        if (errorSinkWriter != null) {\n            try {\n                errorSinkWriter.close();\n            } catch (RuntimeException e) {\n                throw e;\n            } catch (Exception e) {\n                throw new RuntimeException(\"Failed to close error sink writer\", e);\n            }\n        }\n    }\n}\n","sourceCodeStart":270,"sourceCodeEnd":293,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/ErrorHandler.java#L270-L293","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before: close fails silently cascading to RuntimeException\n// after: ensure writer flushed before close\nerrorSinkWriter.prepareCommit();\nerrorSinkWriter.close();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { errorHandler.close(); } catch (RuntimeException e) { log.error(\"ErrorHandler close failed, cause:\", e.getCause()); }","preventionTips":["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"],"tags":["error-sink","close-failed","shutdown"],"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"}