{"record":{"id":"eea8f64e83ad8a2c","repo":"apache/seatunnel","slug":"failed-to-close-ssh-session-eea8f6","errorCode":null,"errorMessage":"Failed to close ssh session","messagePattern":"Failed to close ssh session","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/ScpFileTransfer.java","lineNumber":141,"sourceCode":"        }\n    }\n\n    @Override\n    public void transferAndChown(List<String> sourcePaths, String targetPath) {\n        if (sourcePaths == null) {\n            throw new ClickhouseConnectorException(\n                    CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT, \"sourcePath is null\");\n        }\n        sourcePaths.forEach(sourcePath -> transferAndChown(sourcePath, targetPath));\n    }\n\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}","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ScpFileTransfer.java#L123-L159","documentation":"ScpFileTransfer.close() wraps an IOException from clientSession.close() into SSH_OPERATION_FAILED with the message 'Failed to close ssh session'. Identical in shape to the rsync variant but on the SCP transfer path; it fires during sink shutdown.","triggerScenarios":"close() is invoked and the SCP clientSession.close() throws IOException — connection already dropped, server closed the session, or teardown raced with an in-flight transfer.","commonSituations":"Idle SCP session killed by firewall/NAT during a long job, remote host rebooted, or session already errored from a failed transfer leaving close to fail too.","solutions":["Check logs for the original SSH failure that broke the session; this is often secondary","Verify network stability and SSH keepalive/idle timeouts between worker and host","Retry the job; intermittent failures indicate transient network problems","Confirm sshd is healthy and not rate-limiting or dropping connections"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-job SSH reachability check\nssh -o ConnectTimeout=5 user@host true && echo OK","typeGuard":null,"tryCatchPattern":"try {\n    transfer.close();\n} catch (ClickhouseConnectorException e) {\n    log.warn(\"SCP session close failed; likely already broken connection\", e);\n}","preventionTips":["Enable SSH keepalives to keep sessions alive during long jobs","Investigate the first SSH error in logs, not just the close failure","Retry intermittent network failures"],"tags":["ssh","network","resource-cleanup","scp","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-14T11:17:12.474Z"}