Eu tenho um aplicativo de servidor java básico que tem 100 threads de trabalho que fazem solicitações HEAD simples em urls. Estou usando o HttpClient 4.x para isso.
Depois de alguns minutos, meu programa apenas congela por alguns minutos e não consigo entender por quê. Confira a captura de canvas do relatório visual do monitor da VM. Você pode vê-lo flatline. Durante este tempo eu sou incapaz de obter um bom despejo de thread e visual vm apenas congela até que seja desbloqueado. Alguém tem alguma idéia do que eu posso fazer para tentar depurar esse cara?
Visual VM: http://tinypic.com/view.php?pic=2i915bs&s=7
Aqui está a saída quando tentei tirar um jstack dump enquanto estava congelado:
jstack -F 4325 Attaching to process ID 4325, please wait... Debugger attached successfully. Server compiler detected. JVM version is 16.3-b01 Deadlock Detection: No deadlocks found. Thread 4557: (state = BLOCKED) Error occurred during stack walking: sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.execute(LinuxDebuggerLocal.java:152) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet(LinuxDebuggerLocal.java:466) at sun.jvm.hotspot.debugger.linux.LinuxThread.getContext(LinuxThread.java:65) at sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess.getCurrentFrameGuess(LinuxAMD64JavaThreadPDAccess.java:92) at sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThread.java:256) at sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:218) at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:76) at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45) at sun.jvm.hotspot.tools.JStack.run(JStack.java:60) at sun.jvm.hotspot.tools.Tool.start(Tool.java:221) at sun.jvm.hotspot.tools.JStack.main(JStack.java:86) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at sun.tools.jstack.JStack.runJStackTool(JStack.java:118) at sun.tools.jstack.JStack.main(JStack.java:84) Caused by: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet0(Native Method) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.access$800(LinuxDebuggerLocal.java:51) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1GetThreadIntegerRegisterSetTask.doit(LinuxDebuggerLocal.java:460) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.run(LinuxDebuggerLocal.java:127)
Eu vi vários relatórios de bugs sobre o jstack
no Linux com um rastreio similar:
Você obtém o mesmo resultado com um kill -3
?
Muito provavelmente devido ao uso de muita memory causando GC. Adicione os parâmetros ao java:
-verbosegc -XX:+PrintGCDetails
E veja se você percebe algo óbvio na saída / logs
O que funcionou para mim foi executar o jstack como o proprietário do processo sem -F
.