You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "James Lentini (Jira)" <ji...@apache.org> on 2019/12/06 12:15:00 UTC

[jira] [Commented] (VFS-627) SFTP randomly hangs when copying a file on remote server

    [ https://issues.apache.org/jira/browse/VFS-627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16989683#comment-16989683 ] 

James Lentini commented on VFS-627:
-----------------------------------

I root caused the issue and found a deadlock in JSch. My analysis of the problem and a simple test program to reproduce the issue are at: [https://github.com/jlentini/SftpCopyDeadlock]
 
I also posted a patch to fix the issue to the jsch-users mailing list in this [message|https://sourceforge.net/p/jsch/mailman/message/36872566/].

Note that there is a workaround: use two {{org.apache.commons.vfs2 FileSystemManager}} instances, one for the source file and one for the destination file.

> SFTP randomly hangs when copying a file on remote server
> --------------------------------------------------------
>
>                 Key: VFS-627
>                 URL: https://issues.apache.org/jira/browse/VFS-627
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.1
>         Environment: Java 1.8.0_92
> VFS 2.1
> JSch 0.1.53
>            Reporter: Henri Hagberg
>            Priority: Major
>
> I have a process where a file is first copied over SFTP to local server and then on the remote server the file is copied to another location on that server for archiving. Both are done using {{FileObject#copyFrom}}. Now I've encountered twice the situation where during archiving (on remote server) the copy action hangs indefinitely (the process was left running for over 24 hours). In both cases the issue happened when around 2000 files had been transferred (typical amount is under 100).
> The problem is difficult to reproduce since it doesn't always happen even with large number of files. Based on the stacktrace and random occurrences it might be a concurrency issue. The code using VFS however is single threaded.
> {code}
> Attaching to process ID 128021, please wait...
> Debugger attached successfully.
> Server compiler detected.
> JVM version is 25.92-b14
> Deadlock Detection:
> No deadlocks found.
> Thread 19073: (state = BLOCKED)
> Thread 128165: (state = BLOCKED)
>  - java.lang.Object.wait(long) @bci=0 (Compiled frame; information may be imprecise)
>  - java.lang.ref.ReferenceQueue.remove(long) @bci=59, line=143 (Compiled frame)
>  - org.apache.commons.vfs2.cache.SoftRefFilesCache$SoftRefReleaseThread.run() @bci=26, line=84 (Compiled frame)
> Thread 128164: (state = BLOCKED)
>  - java.lang.Object.wait(long) @bci=0 (Compiled frame; information may be imprecise)
>  - java.io.PipedInputStream.awaitSpace() @bci=23, line=273 (Compiled frame)
>  - java.io.PipedInputStream.receive(byte[], int, int) @bci=31, line=231 (Compiled frame)
>  - java.io.PipedOutputStream.write(byte[], int, int) @bci=77, line=149 (Compiled frame)
>  - com.jcraft.jsch.IO.put(byte[], int, int) @bci=7, line=64 (Compiled frame)
>  - com.jcraft.jsch.Channel.write(byte[], int, int) @bci=7, line=438 (Compiled frame)
>  - com.jcraft.jsch.Session.run() @bci=1260, line=1624 (Compiled frame)
>  - java.lang.Thread.run() @bci=11, line=745 (Interpreted frame)
> Thread 128139: (state = BLOCKED)
> Thread 128138: (state = BLOCKED)
>  - java.lang.Object.wait(long) @bci=0 (Compiled frame; information may be imprecise)
>  - java.lang.ref.ReferenceQueue.remove(long) @bci=59, line=143 (Compiled frame)
>  - java.lang.ref.ReferenceQueue.remove() @bci=2, line=164 (Compiled frame)
>  - java.lang.ref.Finalizer$FinalizerThread.run() @bci=36, line=209 (Interpreted frame)
> Thread 128137: (state = BLOCKED)
>  - java.lang.Object.wait(long) @bci=0 (Compiled frame; information may be imprecise)
>  - java.lang.Object.wait() @bci=2, line=502 (Compiled frame)
>  - java.lang.ref.Reference.tryHandlePending(boolean) @bci=54, line=191 (Compiled frame)
>  - java.lang.ref.Reference$ReferenceHandler.run() @bci=1, line=153 (Interpreted frame)
> Thread 128022: (state = BLOCKED)
>  - java.lang.Object.wait(long) @bci=0 (Compiled frame; information may be imprecise)
>  - com.jcraft.jsch.Session.write(com.jcraft.jsch.Packet, com.jcraft.jsch.Channel, int) @bci=89, line=1261 (Compiled frame)
>  - com.jcraft.jsch.ChannelSftp.sendWRITE(byte[], long, byte[], int, int) @bci=191, line=2619 (Compiled frame)
>  - com.jcraft.jsch.ChannelSftp.access$100(com.jcraft.jsch.ChannelSftp, byte[], long, byte[], int, int) @bci=9, line=36 (Compiled frame)
>  - com.jcraft.jsch.ChannelSftp$1.write(byte[], int, int) @bci=77, line=791 (Compiled frame)
>  - java.io.BufferedOutputStream.write(byte[], int, int) @bci=20, line=122 (Compiled frame)
>  - org.apache.commons.vfs2.util.MonitorOutputStream.write(byte[], int, int) @bci=8, line=123 (Compiled frame)
>  - java.io.BufferedOutputStream.flushBuffer() @bci=20, line=82 (Compiled frame)
>  - java.io.BufferedOutputStream.write(byte[], int, int) @bci=39, line=126 (Compiled frame)
>  - org.apache.commons.vfs2.util.MonitorOutputStream.write(byte[], int, int) @bci=8, line=123 (Compiled frame)
>  - org.apache.commons.vfs2.provider.DefaultFileContent.write(java.io.OutputStream, int) @bci=35, line=892 (Compiled frame)
>  - org.apache.commons.vfs2.provider.DefaultFileContent.write(java.io.OutputStream) @bci=5, line=865 (Compiled frame)
>  - org.apache.commons.vfs2.provider.DefaultFileContent.write(org.apache.commons.vfs2.FileContent) @bci=9, line=828 (Compiled frame)
>  - org.apache.commons.vfs2.provider.DefaultFileContent.write(org.apache.commons.vfs2.FileObject) @bci=7, line=849 (Compiled frame)
>  - org.apache.commons.vfs2.FileUtil.copyContent(org.apache.commons.vfs2.FileObject, org.apache.commons.vfs2.FileObject) @bci=7, line=90 (Compiled frame)
>  - org.apache.commons.vfs2.provider.AbstractFileObject.copyFrom(org.apache.commons.vfs2.FileObject, org.apache.commons.vfs2.FileSelector) @bci=148, line=338 (Compiled frame)
>  ...
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)