{"record":{"id":"b9e95b6499128746","repo":"apache/seatunnel","slug":"failed-to-close-neo4j-sink-writer","errorCode":null,"errorMessage":"Failed to close Neo4j sink writer.","messagePattern":"Failed to close Neo4j sink writer\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-neo4j/src/main/java/org/apache/seatunnel/connectors/seatunnel/neo4j/sink/Neo4jSinkWriter.java","lineNumber":185,"sourceCode":"        }\n    }\n\n    private Throwable appendSuppressed(Throwable existingFailure, Throwable newFailure) {\n        if (existingFailure == null) {\n            return newFailure;\n        }\n        existingFailure.addSuppressed(newFailure);\n        return existingFailure;\n    }\n\n    private void rethrowCloseFailure(Throwable throwable) throws IOException {\n        if (throwable instanceof IOException) {\n            throw (IOException) throwable;\n        }\n        if (throwable instanceof RuntimeException) {\n            throw (RuntimeException) throwable;\n        }\n        throw new IOException(\"Failed to close Neo4j sink writer.\", throwable);\n    }\n\n    private void flushWriteBuffer() {\n        if (!writeBuffer.isEmpty()) {\n            Query query = batchQuery();\n            writeByQuery(query);\n            writeBuffer.clear();\n        }\n    }\n}\n","sourceCodeStart":167,"sourceCodeEnd":196,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-neo4j/src/main/java/org/apache/seatunnel/connectors/seatunnel/neo4j/sink/Neo4jSinkWriter.java#L167-L196","documentation":"Neo4jSinkWriter.close() tears down session and driver resources and collects any Throwable; rethrowCloseFailure() rethrows IOExceptions and RuntimeExceptions as-is, but for any other throwable type (e.g. checked exceptions or driver internals not matching those classes) it wraps it in an IOException with this message. It signals that closing the Neo4j sink writer did not complete cleanly.","triggerScenarios":"close() failing while flushing a non-empty writeBuffer (flushWriteBuffer -> batchQuery/writeByQuery throwing) or while closing the Neo4j session/driver with a non-IOException, non-RuntimeException throwable.","commonSituations":"Flush during close hitting a Neo4j outage; driver internal errors on close; leftover buffered rows after a failed checkpoint being flushed at teardown.","solutions":["Fix the underlying close/flush exception shown as the cause of the IOException","Ensure buffers are flushed via prepareCommit before close so close() has nothing pending","Check Neo4j connectivity at job teardown; retry the job if the failure was transient"],"exampleFix":"// before\n// relying on close() to flush remaining rows\n// after\nwriter.prepareCommit(); // flush buffer explicitly before close\nwriter.close();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { writer.close(); } catch (IOException e) { if (e.getMessage().contains(\"Failed to close Neo4j sink writer\")) { log.error(\"neo4j close failed\", e.getCause()); } throw e; }","preventionTips":["Call prepareCommit before close so the buffer is empty at teardown","Ensure Neo4j is reachable during job teardown","Log and inspect e.getCause() for the true failure"],"tags":["java","neo4j","close","resource-cleanup"],"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-14T11:17:12.474Z"}