{"record":{"id":"153e97f0da8e3b3b","repo":"apache/seatunnel","slug":"failed-to-close-ssh-client","errorCode":null,"errorMessage":"Failed to close ssh client","messagePattern":"Failed to close ssh client","errorType":"exception","errorClass":"ClickhouseConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/RsyncFileTransfer.java","lineNumber":191,"sourceCode":"\n    @Override\n    public void close() {\n        if (clientSession != null && clientSession.isOpen()) {\n            try {\n                clientSession.close();\n            } catch (IOException e) {\n                throw new ClickhouseConnectorException(\n                        ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED,\n                        \"Failed to close ssh session\",\n                        e);\n            }\n        }\n        if (sshClient != null && sshClient.isOpen()) {\n            sshClient.stop();\n            try {\n                sshClient.close();\n            } catch (IOException e) {\n                throw new ClickhouseConnectorException(\n                        ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED,\n                        \"Failed to close ssh client\",\n                        e);\n            }\n        }\n    }\n}\n","sourceCodeStart":173,"sourceCodeEnd":199,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/RsyncFileTransfer.java#L173-L199","documentation":"RsyncFileTransfer.close() wraps an IOException thrown while closing the SshClient itself (after stop()) into SSH_OPERATION_FAILED. The session may have closed fine but the underlying client teardown failed. It is thrown during sink lifecycle shutdown.","triggerScenarios":"close() reaches sshClient.close() and it throws IOException — e.g. the client's executor/IO threads are wedged, or the client was already stopped/closed elsewhere and the underlying transport errors on shutdown.","commonSituations":"Job cancellation racing with sink close (double close), JVM thread pool exhaustion preventing sshd's NioWorker from shutting down, or an earlier SSH failure leaving the client in a broken state.","solutions":["Check for earlier SSH errors in the log; this is usually a secondary symptom of an earlier failure","Ensure the sink is not closed twice concurrently (check job retry/cancel logic)","Confirm adequate thread resources for the SSH client's IO threads on the worker","Retry the job; verify host connectivity and sshd health"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    transfer.close();\n} catch (ClickhouseConnectorException e) {\n    log.warn(\"Ignoring ssh client close failure during shutdown\", e); // secondary symptom, don't mask root cause\n}","preventionTips":["Check for an earlier root-cause SSH error before treating close failure as primary","Avoid double-closing the transfer from concurrent cancel/retry paths","Ensure worker has adequate threads for SSH IO"],"tags":["ssh","network","resource-cleanup","clickhouse"],"backgroundTag":"network-request-failed","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"}