SftpFileSystem using a single channel#864
Merged
Merged
Conversation
Synchronize sending messages through the channel. Messages would be synchronized at the connection level anyway, and most uses of SFTP will be single-threaded anyway, so synchronizing on channel level should not impact performance much. With a thread-safe SftpClient, the use of SftpClients in the SftpFileSystem can be simplified.
Drop the SftpClient pool and use a single thread-safe SftpClient per SftpFileSystem. The SftpClient is closed when the file system is closed. If the server side should close the channel, operations using this client may fail, but a server should not close channels unless there is no traffic. If a channel is closed by the server because it is idle, the SftpFileSystem will re-create a new SftpClient, thus opening a new channel, on the next operation. It is possible that a server decides to close a previously idle channel just in the moment the client-side wants to use that channel for a new operation. The new operation would then fail. But this possibility has always existed in all previous versions of the SftpFileSystem code. The main advantage of using a single SftpClient is that all SFTP operations are done in the same channel. This can be important with servers that restrict the number of concurrently open channels per SSH session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use a thread-safe
SftpClient, serializing all writes for SFTP commands or data over a single SSH channel. If needed, re-create the channel (andSftpClient) if it gets closed by the server side.As a result, an
SftpFileSystemuses a single SSH channel.Fixes #855.