Java 应用程序在 Linux 上的“java.io.UnixFileSystem.getBooleanAttributes0”处挂起
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/224756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java Application Hang on Linux at "java.io.UnixFileSystem.getBooleanAttributes0"
提问by
Our customers application seems to hang with the following stack trace:
我们的客户应用程序似乎挂起以下堆栈跟踪:
java.lang.Thread.State: RUNNABLE
at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
at java.io.UnixFileSystem.getBooleanAttributes(Unknown Source)
at java.io.File.isFile(Unknown Source)
at org.tmatesoft.svn.core.internal.wc.SVNFileType.getType(SVNFileType.java:118)
at org.tmatesoft.svn.core.internal.wc.SVNFileUtil.createUniqueFile(SVNFileUtil.java:299)
- locked <0x92ebb2a0> (a java.lang.Class for org.tmatesoft.svn.core.internal.wc.SVNFileUtil)
at org.tmatesoft.svn.core.internal.wc.SVNRemoteDiffEditor.createTempFile(SVNRemoteDiffEditor.java:415)
at org.tmatesoft.svn.core.internal.wc.SVNRemoteDiffEditor.applyTextDelta(SVNRemoteDiffEditor.java:255)
Anyone know what could cause it to hang in isFile?
任何人都知道是什么导致它挂在 isFile 中?
回答by Chris Jester-Young
getBooleanAttributes0calls stat(or stat64, if available). If you have the OpenJDK source code, this is listed in file jdk/src/solaris/native/java/io/UnixFileSystem_md.c.
getBooleanAttributes0调用stat(或stat64,如果可用)。如果您有 OpenJDK 源代码,它会在文件jdk/src/solaris/native/java/io/UnixFileSystem_md.c.
So the real question is, why is statfrozen? Is the file being accessed a network file on a server that's down, for example? If this is a reproducible problem, you may wish to use straceto attach to the Java process, just prior to the freezing. Then look in the output for calls to stat, to see what's being accessed.
所以真正的问题是,为什么会被stat冻结?例如,正在访问的文件是否是停机服务器上的网络文件?如果这是一个可重现的问题,您可能希望strace在冻结之前使用附加到 Java 进程。然后在输出中查看对 的调用stat,以查看正在访问的内容。
回答by staffan
Looks like the statcall that results from getBooleanAttributes0is blocking. This typically happens because the file is located on an NFS share which is down.
看起来由此产生的stat调用getBooleanAttributes0正在阻塞。这通常是因为文件位于已关闭的 NFS 共享上。
回答by James Blackburn
We see this issue in Eclipse when it stats a non-existent file in a NFS automount directory.
当 Eclipse 统计 NFS 自动挂载目录中不存在的文件时,我们会在 Eclipse 中看到此问题。
If you strace your java process with -f -t -T (follow forks and time) what we see is that mostthe stats return in a very short time. The ones in the automount directory take two orders of magnitudes longer.
如果您使用 -f -t -T(跟随叉子和时间)跟踪您的 Java 进程,我们会看到大多数统计信息在很短的时间内返回。automount 目录中的那些需要两个数量级的时间。
In many cases the OS takes this as an opportunity to context switch the thread out. The result is that the thread performing the stat is not running for a very long time. If your Java code (an Eclipse plugin in our case) is inefficiently stating up the tree recursively for every file, you can end up locking up that thread for a long time.
在许多情况下,操作系统将此作为上下文切换线程的机会。结果是执行 stat 的线程很长时间没有运行。如果您的 Java 代码(在我们的例子中是一个 Eclipse 插件)为每个文件递归地声明树的效率低下,您最终可能会锁定该线程很长时间。
The solution, is to stop your Java from doing that.
解决方案是阻止您的 Java 这样做。
回答by Chris Kimpton
No idea, but the obvious question of which JDK/JRE comes to mind and what others have you tried...
不知道,但很明显的问题是想到哪个 JDK/JRE 以及您尝试过哪些其他的……
回答by Paul Whelan
Perhaps the SVN repository is somehow locked All I can do is guess.
也许 SVN 存储库以某种方式被锁定了我所能做的就是猜测。
Does the application access a subversion repository?
应用程序是否访问 subversion 存储库?
It might be waiting for the repository to be not locked again, who knows its your application.
它可能正在等待存储库不再锁定,谁知道它是您的应用程序。

