New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deadlock when using SFTP CachingSessionFactory with FileExistsMode.FAIL #3249
Comments
The
We should not call that Good catch! I'll try to fix it over weekend. |
artembilan
added a commit
to artembilan/spring-integration
that referenced
this issue
Apr 19, 2020
Fixes: spring-projects#3249 When the `CachingSessionFactory` is configured with small enough pool and it is very likely that dead lock may happen when `RemoteFileTemplate.send()` is used. The problem happens when we reach the `RemoteFileTemplate.exists()` call which is done from the internal method called from already pulled from cache `Session` * Fix `RemoteFileTemplate` to use a `session.exists()` instead on the provided into the method `Session` * Demonstrate the problem in the `SftpRemoteFileTemplateTests.testNoDeadLockOnSend()` **Cherry-pick to 5.2.x, 5.1.x & 4.3.x**
Reopen: merged to the See linked PR for |
garyrussell
pushed a commit
that referenced
this issue
Apr 20, 2020
Fixes: #3249 When the `CachingSessionFactory` is configured with small enough pool and it is very likely that dead lock may happen when `RemoteFileTemplate.send()` is used. The problem happens when we reach the `RemoteFileTemplate.exists()` call which is done from the internal method called from already pulled from cache `Session` * Fix `RemoteFileTemplate` to use a `session.exists()` instead on the provided into the method `Session` * Demonstrate the problem in the `SftpRemoteFileTemplateTests.testNoDeadLockOnSend()` **Cherry-pick to 5.2.x, 5.1.x & 4.3.x** Fix RemoteFileOutboundGWTests for the proper mock
garyrussell
pushed a commit
that referenced
this issue
Apr 20, 2020
Fixes: #3249 When the `CachingSessionFactory` is configured with small enough pool and it is very likely that dead lock may happen when `RemoteFileTemplate.send()` is used. The problem happens when we reach the `RemoteFileTemplate.exists()` call which is done from the internal method called from already pulled from cache `Session` * Fix `RemoteFileTemplate` to use a `session.exists()` instead on the provided into the method `Session` * Demonstrate the problem in the `SftpRemoteFileTemplateTests.testNoDeadLockOnSend()` **Cherry-pick to 5.2.x, 5.1.x & 4.3.x** Fix RemoteFileOutboundGWTests for the proper mock
Fixed with the merged PR. |
garyrussell
pushed a commit
that referenced
this issue
Apr 20, 2020
Fixes: #3249 When the `CachingSessionFactory` is configured with small enough pool and it is very likely that dead lock may happen when `RemoteFileTemplate.send()` is used. The problem happens when we reach the `RemoteFileTemplate.exists()` call which is done from the internal method called from already pulled from cache `Session` * Fix `RemoteFileTemplate` to use a `session.exists()` instead on the provided into the method `Session` * Demonstrate the problem in the `SftpRemoteFileTemplateTests.testNoDeadLockOnSend()` **Cherry-pick to 5.2.x, 5.1.x & 4.3.x** Fix RemoteFileOutboundGWTests for the proper mock
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Affects 5.2.5
It looks like there is a deadlock when using a
CachingSessionFactory
andFileExistsMode.FAIL
. WhenFileExistsMode.FAIL
is used, then we first check if the file exists in the server by callingRemoteFileTemplate#exists
which in turn callsRemoteFileTemplate#execute
. The latter requests a new session to the session factory instead of using the session already obtained (RemoteFileTemplate#activeTemplateCallbacks
size always evaluated to 0 during my tests). This can end up in a deadlock situation if there are as many (or less) cached sessions as the number of concurrent threads (possibly with more too).Below is a test I used to reproduce this locally using 2 concurrent threads and 2 cached sessions. I omitted some details for brevity. Hopefully it is enough to reproduce it on your side.
The text was updated successfully, but these errors were encountered: