最近,我们刚刚注意到我们的许多服务器偶尔突然(没有明显的逐渐降级)锁定到以下堆栈(所有其他线程都是 BLOCKED、IN_NATIVE 或 IN_VM)(在我们的代码开始处截断),使用 jstack -F 获得
Thread 18334: (state = IN_JAVA)
- java.util.Calendar.updateTime() @bci=1, line=2469 (Compiled frame; information may be imprecise)
- java.util.Calendar.getTimeInMillis() @bci=8, line=1088 (Compiled frame)
(truncated)
失败似乎是在full gc后不久发生的,top -H -p显示有两个线程,一个似乎是上面的线程,另一个是gc线程或jitc,根据pstack的以下输出(不是 VMThread::run()):
Thread 331 (Thread 0x7f59641bc700 (LWP 16461)):
#0 0x00007f63f9ed0ef8 in SafepointSynchronize::begin() () from /usr/java/jdk1.6.0_33/jre/lib/amd64/server/libjvm.so
#1 0x00007f63f9fbab7c in VMThread::loop() () from /usr/java/jdk1.6.0_33/jre/lib/amd64/server/libjvm.so
#2 0x00007f63f9fba68e in VMThread::run() () from /usr/java/jdk1.6.0_33/jre/lib/amd64/server/libjvm.so
#3 0x00007f63f9e5e7af in java_start(Thread*) () from /usr/java/jdk1.6.0_33/jre/lib/amd64/server/libjvm.so
#4 0x00000035bb807851 in start_thread () from /lib64/libpthread.so.0
#5 0x00000035bb4e811d in clone () from /lib64/libc.so.6
有谁知道为什么这可能已经开始发生?
我们在 CentOS 5.7 版和 6.3 版上使用 jdk1.6.0_33,在 24 核(12 个物理)的服务器上。
这里还有一些堆栈,我们的代码被截断了:
Thread 22561: (state = IN_VM)
- java.lang.String.toLowerCase(java.util.Locale) @bci=428, line=2782 (Compiled frame; information may be imprecise)
- java.lang.String.toLowerCase() @bci=4, line=2847 (Compiled frame)
(truncated)
Thread 22562: (state = IN_VM)
- java.util.HashMap.put(java.lang.Object, java.lang.Object) @bci=20, line=403 (Compiled frame; information may be imprecise)
- java.util.HashSet.add(java.lang.Object) @bci=8, line=200 (Compiled frame)
(truncated)
Thread 22558: (state = BLOCKED)
- sun.nio.ch.EPollSelectorImpl.wakeup() @bci=6, line=173 (Compiled frame)
- org.mortbay.io.nio.SelectorManager$SelectSet.wakeup() @bci=10, line=706 (Compiled frame)
- org.mortbay.io.nio.SelectChannelEndPoint.updateKey() @bci=135, line=344 (Compiled frame)
- org.mortbay.io.nio.SelectChannelEndPoint.undispatch() @bci=10, line=204 (Compiled frame)
- org.mortbay.jetty.nio.SelectChannelConnector$ConnectorEndPoint.undispatch() @bci=54, line=382 (Compiled frame)
- org.mortbay.io.nio.SelectChannelEndPoint.run() @bci=44, line=449 (Compiled frame)
- org.mortbay.thread.QueuedThreadPool$PoolThread.run() @bci=25, line=534 (Compiled frame)
Thread 22557: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Compiled frame; information may be imprecise)
- java.lang.Object.wait(long, int) @bci=58, line=443 (Compiled frame)
- com.stumbleupon.async.Deferred.doJoin(boolean, long) @bci=244, line=1148 (Compiled frame)
- com.stumbleupon.async.Deferred.join(long) @bci=3, line=1028 (Compiled frame)
(truncated)
Thread 20907: (state = IN_NATIVE)
- java.net.PlainSocketImpl.socketAccept(java.net.SocketImpl) @bci=0 (Interpreted frame)
- java.net.PlainSocketImpl.accept(java.net.SocketImpl) @bci=7, line=408 (Interpreted frame)
- java.net.ServerSocket.implAccept(java.net.Socket) @bci=60, line=462 (Interpreted frame)
- java.net.ServerSocket.accept() @bci=48, line=430 (Interpreted frame)
- sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop() @bci=55, line=369 (Interpreted frame)
- sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run() @bci=1, line=341 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=662 (Interpreted frame)
Thread 22901: (state = IN_NATIVE)
- sun.nio.ch.EPollArrayWrapper.epollWait(long, int, long, int) @bci=0 (Compiled frame; information may be imprecise)
- sun.nio.ch.EPollArrayWrapper.poll(long) @bci=18, line=210 (Compiled frame)
- sun.nio.ch.EPollSelectorImpl.doSelect(long) @bci=28, line=65 (Compiled frame)
- sun.nio.ch.SelectorImpl.lockAndDoSelect(long) @bci=37, line=69 (Compiled frame)
- sun.nio.ch.SelectorImpl.select(long) @bci=30, line=80 (Compiled frame)
- net.spy.memcached.MemcachedConnection.handleIO() @bci=126, line=188 (Compiled frame)
- net.spy.memcached.MemcachedClient.run() @bci=11, line=1591 (Compiled frame)