从 SFTP 读取时 jsch 线程挂起

发布于 2025-01-09 08:45:47 字数 3457 浏览 1 评论 0原文

我注意到从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文