从 SFTP 读取时 jsch 线程挂起
我注意到从 SFTP 服务器读取数据的速度很慢,我有 10 个并行进程在不同的容器中运行,它们正在读取这些数据,并且通常在一个容器中随机观察到速度缓慢。我正在使用 commons-vfs 从 SFTP 服务器读取数据,并且我扩展了 SFTP 相关类来添加排序逻辑。我正在使用 centos-7.9 来托管我的 SFTP 服务器。 我注意到读取器线程处于阻塞状态并等待监视器线程释放锁。
有人可以指导我如何解决这个问题吗?
"Thread-135" #150 prio=5 os_prio=0 tid=0x00007f1e3808d800 nid=0x3a2 waiting for monitor entry [0x00007f1ea5eed000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.apache.commons.vfs2.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:306)
- waiting to lock <0x00000005cedf23f8> (a org.apache.commons.vfs2.provider.sftp.MySftpFileSystem)
at org.apache.commons.vfs2.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:301)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:76)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:56)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:711)
at org.apache.commons.vfs2.impl.DefaultVfsComponentContext.resolveFile(DefaultVfsComponentContext.java:46)
at org.apache.commons.vfs2.provider.AbstractLayeredFileProvider.findFile(AbstractLayeredFileProvider.java:54)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:711)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:677)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:632)
at com.sqlstream.aspen.namespace.filevfs.FileVFSInputSource$FileReader.run(FileVFSInputSource.java:894)
at java.lang.Thread.run(Thread.java:748)
"Thread-134" #149 daemon prio=1 os_prio=0 tid=0x00007f1e381e7800 nid=0x3a1 in Object.wait() [0x00007f1ea6af9000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.io.PipedInputStream.read(PipedInputStream.java:326)
- eliminated <0x00000005d821ea90> (a com.jcraft.jsch.Channel$MyPipedInputStream)
at java.io.PipedInputStream.read(PipedInputStream.java:377)
- locked <0x00000005d821ea90> (a com.jcraft.jsch.Channel$MyPipedInputStream)
at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2909)
at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2935)
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1643)
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1553)
at org.apache.commons.vfs2.provider.sftp.MySftpFileObject.doListChildrenResolved(MySftpFileObject.java:376)
at org.apache.commons.vfs2.provider.AbstractFileObject.getChildren(AbstractFileObject.java:1081)
- locked <0x00000005cedf23f8> (a org.apache.commons.vfs2.provider.sftp.MySftpFileSystem)
at com.sqlstream.aspen.namespace.filevfs.MyFileMonitor$FileMonitorAgent.checkForNewChildren(MyFileMonitor.java:458)
at com.sqlstream.aspen.namespace.filevfs.MyFileMonitor$FileMonitorAgent.check(MyFileMonitor.java:543)
at com.sqlstream.aspen.namespace.filevfs.MyFileMonitor$FileMonitorAgent.access$200(MyFileMonitor.java:376)
at com.sqlstream.aspen.namespace.filevfs.MyFileMonitor.run(MyFileMonitor.java:321)
at java.lang.Thread.run(Thread.java:748)
I have noticed slowness in reading data from SFTP server, I have 10 parallel processes running in the different containers which are reading this data and slowness is usually observed in one container randomly. I am using commons-vfs to read data from SFTP server and I have extended SFTP related classes to add come sort logic. I am using centos-7.9 to host my SFTP server.
I have noticed the reader thread is in blocked state and waiting for monitor thread to release lock.
Can someone please guide me on how to fix this issue.
"Thread-135" #150 prio=5 os_prio=0 tid=0x00007f1e3808d800 nid=0x3a2 waiting for monitor entry [0x00007f1ea5eed000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.apache.commons.vfs2.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:306)
- waiting to lock <0x00000005cedf23f8> (a org.apache.commons.vfs2.provider.sftp.MySftpFileSystem)
at org.apache.commons.vfs2.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:301)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:76)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:56)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:711)
at org.apache.commons.vfs2.impl.DefaultVfsComponentContext.resolveFile(DefaultVfsComponentContext.java:46)
at org.apache.commons.vfs2.provider.AbstractLayeredFileProvider.findFile(AbstractLayeredFileProvider.java:54)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:711)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:677)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:632)
at com.sqlstream.aspen.namespace.filevfs.FileVFSInputSource$FileReader.run(FileVFSInputSource.java:894)
at java.lang.Thread.run(Thread.java:748)
"Thread-134" #149 daemon prio=1 os_prio=0 tid=0x00007f1e381e7800 nid=0x3a1 in Object.wait() [0x00007f1ea6af9000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.io.PipedInputStream.read(PipedInputStream.java:326)
- eliminated <0x00000005d821ea90> (a com.jcraft.jsch.Channel$MyPipedInputStream)
at java.io.PipedInputStream.read(PipedInputStream.java:377)
- locked <0x00000005d821ea90> (a com.jcraft.jsch.Channel$MyPipedInputStream)
at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2909)
at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2935)
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1643)
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1553)
at org.apache.commons.vfs2.provider.sftp.MySftpFileObject.doListChildrenResolved(MySftpFileObject.java:376)
at org.apache.commons.vfs2.provider.AbstractFileObject.getChildren(AbstractFileObject.java:1081)
- locked <0x00000005cedf23f8> (a org.apache.commons.vfs2.provider.sftp.MySftpFileSystem)
at com.sqlstream.aspen.namespace.filevfs.MyFileMonitor$FileMonitorAgent.checkForNewChildren(MyFileMonitor.java:458)
at com.sqlstream.aspen.namespace.filevfs.MyFileMonitor$FileMonitorAgent.check(MyFileMonitor.java:543)
at com.sqlstream.aspen.namespace.filevfs.MyFileMonitor$FileMonitorAgent.access$200(MyFileMonitor.java:376)
at com.sqlstream.aspen.namespace.filevfs.MyFileMonitor.run(MyFileMonitor.java:321)
at java.lang.Thread.run(Thread.java:748)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论