{"record":{"id":"70249631ba1c98c2","repo":"apache/seatunnel","slug":"failed-to-close-ssh-client-702496","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/ScpFileTransfer.java","lineNumber":152,"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":134,"sourceCodeEnd":160,"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#L134-L160","documentation":"ScpFileTransfer.close() wraps an IOException from sshClient.close() (after stop()) into SSH_OPERATION_FAILED with 'Failed to close ssh client'. Thrown during sink lifecycle shutdown when the SSH client teardown fails.","triggerScenarios":"close() reaches sshClient.close() and it throws — usually a secondary symptom of an earlier connection failure, double-close from a concurrent cancel, or IO threads unable to shut down cleanly.","commonSituations":"Job cancellation racing sink close, prior SCP failure leaving the client broken, or thread/resource exhaustion on the SeaTunnel worker.","solutions":["Look for the first/underlying SSH error in the logs; this is typically a follow-on failure","Avoid double-closing the transfer (check retry/cancel handling)","Ensure the worker has enough threads/resources for the SSH client","Retry the job and verify host connectivity"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    transfer.close();\n} catch (ClickhouseConnectorException e) {\n    log.warn(\"SSH client close failed during shutdown; treating as non-fatal\", e);\n}","preventionTips":["Treat close failures as secondary symptoms; fix the root SSH failure","Guard against concurrent/double close during job cancel","Keep worker resources (threads) sufficient for SSH client teardown"],"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"}