{"record":{"id":"60ab7f4d92429745","repo":"apache/seatunnel","slug":"trace-file-already-closed","errorCode":null,"errorMessage":"Trace file already closed: {}","messagePattern":"Trace file already closed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/event/TraceFileWriter.java","lineNumber":145,"sourceCode":"        return date;\n    }\n\n    @Override\n    public void close() throws IOException {\n        if (!closed.compareAndSet(false, true)) {\n            return;\n        }\n        try {\n            writer.close();\n            log.info(\n                    \"Closed trace file: {} (events={}, size={} bytes)\",\n                    filePath,\n                    eventCount.get(),\n                    fileSize.get());\n        } catch (IOException e) {\n            if (e instanceof ClosedChannelException\n                    || (e.getMessage() != null && e.getMessage().contains(\"Stream closed\"))) {\n                log.warn(\"Trace file already closed: {}\", filePath);\n                return;\n            }\n            log.error(\"Failed to close trace file: \" + filePath, e);\n            throw e;\n        }\n    }\n}\n","sourceCodeStart":127,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/event/TraceFileWriter.java#L127-L153","documentation":"TraceFileWriter.close() logs this warning when the file channel is already closed (ClosedChannelException or 'Stream closed'). This can happen when close is invoked twice or the channel was closed elsewhere; the writer treats it as benign and returns instead of rethrowing.","triggerScenarios":"close() is called on a TraceFileWriter whose channel was already closed — e.g. double close during handler shutdown, or the writer was closed concurrently by another shutdown path.","commonSituations":"Overlapping shutdown paths (scheduler close + handler close) both attempting to close the same trace file; roll-and-close logic racing at rotation time.","solutions":["None required — this is intentionally handled as a benign no-op.","If frequent, audit close() call sites to ensure single-owner closing of the writer under writerLock."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { writer.close(); } catch (IOException e) { if (e instanceof ClosedChannelException) { /* already closed, ignore */ } else { throw e; } }","preventionTips":["Close the writer from a single owner under a lock.","Use idempotent close logic (guard with a closed flag)."],"tags":["io","shutdown","file"],"backgroundTag":"file-already-exists","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}