2013-02-03 37 views
0

我们在tomcat节点中看到了一些奇怪的问题。我花了线程转储来查看线程状态。在大多数线程处于IN_NATIVE状态。有人能告诉我这是什么以及是什么造成的?这是线程的堆栈跟踪。很多线程处于IN_NATIVE状态

Thread 677: (state = IN_NATIVE) 
- java.net.SocketInputStream.socketRead0(java.io.FileDescriptor, byte[], int, int, int) @bci=0 (Compiled frame; information may be imprecise) 
- java.net.SocketInputStream.read(byte[], int, int) @bci=84, line=129 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.InputRecord.readFully(java.io.InputStream, byte[], int, int) @bci=21, line=293 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.InputRecord.read(java.io.InputStream, java.io.OutputStream) @bci=32, line=331 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(com.sun.net.ssl.internal.ssl.InputRecord, boolean) @bci=44, line=789 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(com.sun.net.ssl.internal.ssl.InputRecord) @bci=15, line=746 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.AppInputStream.read(byte[], int, int) @bci=30, line=75 (Compiled frame) 
- java.io.BufferedInputStream.fill() @bci=175, line=218 (Compiled frame) 
- java.io.BufferedInputStream.read1(byte[], int, int) @bci=44, line=258 (Compiled frame) 
- java.io.BufferedInputStream.read(byte[], int, int) @bci=49, line=317 (Compiled frame) 
- com.sun.jndi.ldap.Connection.run() @bci=30, line=808 (Compiled frame) 
- java.lang.Thread.run() @bci=11, line=619 (Interpreted frame) 


Thread 675: (state = IN_NATIVE) 
- java.net.SocketInputStream.socketRead0(java.io.FileDescriptor, byte[], int, int, int) @bci=0 (Compiled frame; information may be imprecise) 
- java.net.SocketInputStream.read(byte[], int, int) @bci=84, line=129 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.InputRecord.readFully(java.io.InputStream, byte[], int, int) @bci=21, line=293 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.InputRecord.read(java.io.InputStream, java.io.OutputStream) @bci=32, line=331 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(com.sun.net.ssl.internal.ssl.InputRecord, boolean) @bci=44, line=789 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(com.sun.net.ssl.internal.ssl.InputRecord) @bci=15, line=746 (Compiled frame) 
- com.sun.net.ssl.internal.ssl.AppInputStream.read(byte[], int, int) @bci=30, line=75 (Compiled frame) 
- java.io.BufferedInputStream.fill() @bci=175, line=218 (Compiled frame) 
- java.io.BufferedInputStream.read1(byte[], int, int) @bci=44, line=258 (Compiled frame) 
- java.io.BufferedInputStream.read(byte[], int, int) @bci=49, line=317 (Compiled frame) 
- com.sun.jndi.ldap.Connection.run() @bci=30, line=808 (Compiled frame) 
- java.lang.Thread.run() @bci=11, line=619 (Interpreted frame) 

全部Threaddump是@ https://docs.google.com/document/d/16YnK85jrlxvu_PpQrTQxtIWjWmAlt8AF1ddAOzvisCM/edit?usp=sharing

+0

线程被阻塞用于输入数据,可能正在等待来自mysql服务器的数据。如果没有数据被等待,那么你已经陷入了mysql服务器的bug。检查'show processlist'以查看是否有查询正在执行,如果不是 - 这是bug:http://bugs.mysql.com/bug.php?id=24995 – bestsss

+0

@bestsss与MySQL无关。查看堆栈跟踪。 – EJP

+0

看起来像mysql导致这一点,但我不知道,因为我看到一堆缓慢的查询在同一时间约20至30秒的日志。我仍然无法找到原因。帮助赞赏。提前致谢。 – Chandu

回答

2

的Java写有点像一个包装语言C++。有些库仍然使用C++并使用java关键字native。

这基本上意味着他们调用了一个现在在c/C++代码中执行的本地方法。

+0

在这种特殊情况下,线程在套接字读取时被阻塞,它并没有执行任何东西 – bestsss

+0

看起来像是mysql造成这种情况,但我不确定,因为我在同一时间看到一堆慢速查询, 30秒。我仍然无法找到原因。帮助赞赏。提前致谢。 – Chandu

+0

你可以发布整个线程转储吗?检测实际发生的事情会更容易。 – Kurtymckurt

1

线程被阻塞,从LDAP服务器通过SSL进行读取。查看堆栈跟踪。