{"record":{"id":"3bfdd98167f670f3","repo":"apache/seatunnel","slug":"iotdbconnectorerrorcode-close-session-failed","errorCode":"IotdbConnectorErrorCode.CLOSE_SESSION_FAILED","errorMessage":"Close IoTDB session failed","messagePattern":"Close IoTDB session failed","errorType":"error_code","errorClass":"IotdbConnectorException","httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-iotdb-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/source/IoTDBv2SourceReader.java","lineNumber":69,"sourceCode":"            ReadonlyConfig conf, SourceReader.Context readerContext, SeaTunnelRowType rowType) {\n        super(conf, readerContext);\n        this.deserializer = new DefaultSeaTunnelRowDeserializer(rowType, SourceConstants.TREE);\n    }\n\n    @Override\n    public void open() throws Exception {\n        session = buildSession(conf);\n        session.open();\n    }\n\n    @Override\n    public void close() throws IOException {\n        try {\n            if (session != null) {\n                session.close();\n            }\n        } catch (IoTDBConnectionException e) {\n            throw new IotdbConnectorException(\n                    IotdbConnectorErrorCode.CLOSE_SESSION_FAILED, \"Close IoTDB session failed\", e);\n        }\n    }\n\n    private Session buildSession(ReadonlyConfig conf) {\n        Session.Builder sessionBuilder = new Session.Builder();\n        List<String> nodes = conf.get(NODE_URLS);\n        sessionBuilder.nodeUrls(nodes);\n        if (null != conf.get(FETCH_SIZE)) {\n            sessionBuilder.fetchSize(Integer.parseInt(conf.get(FETCH_SIZE).toString()));\n        }\n        if (null != conf.get(USERNAME)) {\n            sessionBuilder.username(conf.get(USERNAME));\n        }\n        if (null != conf.get(PASSWORD)) {\n            sessionBuilder.password(conf.get(PASSWORD));\n        }\n        if (null != conf.get(DEFAULT_THRIFT_BUFFER_SIZE)) {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iotdb-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/source/IoTDBv2SourceReader.java#L51-L87","documentation":"Thrown by IoTDBv2SourceReader.close() when closing the IoTDB Session raises IoTDBConnectionException. The read itself already completed; this is a cleanup-path failure releasing the session back to the server. Since close() declares IOException, this error propagates to the reader lifecycle handling.","triggerScenarios":"session.close() fails because the connection to IoTDB is already dead (server restarted, network drop, idle eviction), or the session was already closed elsewhere.","commonSituations":"Long-running job where IoTDB restarts or the connection times out before close; job cancellation after a network outage; IoTDB killed abruptly so the TCP close handshake fails.","solutions":["Usually safe to ignore if all data was read; the session resources are released on the server by timeout","Check IoTDB server availability/logs if this appears alongside read failures","Ensure only one close() path exists (avoid double-close); guard with a flag if needed","Verify network stability between workers and IoTDB to reduce stale connections"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"if (session == null) return; // nothing to close","tryCatchPattern":"try {\n    reader.close();\n} catch (IOException e) {\n    if (e instanceof IotdbConnectorException\n            && IotdbConnectorErrorCode.CLOSE_SESSION_FAILED.equals(((IotdbConnectorException) e).getSeaTunnelErrorCode())) {\n        log.warn(\"Session close failed after read completion; resources will expire server-side\", e);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Treat close failures as non-fatal if all data was consumed and acked","Avoid double-closing sessions; track close state","Monitor IoTDB restarts/timeouts which leave stale sessions","Keep session idle/connection timeouts aligned between client and server"],"tags":["iotdb","session-close","cleanup","connection"],"backgroundTag":"connection-refused","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"}