對于我們的應用程式的一次安裝,我們一直看到生産中的問題被使用者報告為“系統變慢”或“請求永不傳回”.最後,伺服器必須重新啟動.我們有幾個這樣的事件,每晚重新開機伺服器似乎是一個解決方法.
我們的應用程式大量使用動态類加載(存儲在@R_301_457@中的.jar檔案作為blob)和反射.
環境細節:
> Java 1.7.021
>作業系統:Linux(2.6.32-504.16.2.el6.x86_64)
> JBoss EAP 6.2
> Appdynamics正在使用
>記憶體和gc設定:-XX:PermSize = 256m -XX:MaxPermSize = 2560m -Xms2048m -Xmx10240m -server -XX:UseParallelGC -XX:UseParallelOldGC
我們切換到了
> Java 1.7.080
> -XX:UseG1GC
但看起來我們仍然面臨着這個問題.
我們在logfiles,heapdumps,threadumps和gc日志中看到的内容如下所示
>我們沒有看到任何OutOfMemory錯誤
> Heap和PermGend的記憶體消耗似乎沒問題(堆和perm gen未完全使用)
>使用Java 1.7.021和parallelGC,我們看到了幾個長時間運作(5分鐘)的Full GC – 在切換到G1GC後這似乎不再發生(這是我們的預期)
>我們在日志中看不到任何與CodeCache相關的警告
我們看到的是
>對于某些事件,heapdump中DelegatingClassLoaders的數量約為5000,而其他事件則約為10萬.
>在使用者初始報告系統變慢之後,狀态為RUNNABLE且正在處理“getDeclaredConstructors0”的線程數正在增加(從開頭隻有兩個到大約50個.線程似乎“挂起”多個小時的相同位置(它們處于RUNNABLE狀态).
有關該線程組的摘錄,請參見下文:
"http-xxx:8443-141" daemon prio=10 tid=0x00007efe9412f000 nid=0x64fb runnable [0x00007efe1ba8a000]
java.lang.Thread.State: RUNNABLE
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413)
at java.lang.Class.getConstructor0(Class.java:2723)
at java.lang.Class.newInstance0(Class.java:345)
at java.lang.Class.newInstance(Class.java:327)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
at sun.reflect.MethodAccessorGenerator.generateMethod(MethodAccessorGenerator.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:46)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
[application code]
"http-xxx:8443-138" daemon prio=10 tid=0x00007efe9412a000 nid=0x64ed runnable [0x00007efe1c397000]
java.lang.Thread.State: RUNNABLE
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413)
at java.lang.Class.getConstructor0(Class.java:2723)
at java.lang.Class.newInstance0(Class.java:345)
at java.lang.Class.newInstance(Class.java:327)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
at sun.reflect.MethodAccessorGenerator.generateMethod(MethodAccessorGenerator.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:46)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.mvel2.PropertyAccessor.set(PropertyAccessor.java:350)
at org.mvel2.PropertyAccessor.set(PropertyAccessor.java:134)
at org.mvel2.MVEL.setProperty(MVEL.java:1088)
[application code]
更新到Java 1.7.80 / G1Gc後的情況似乎相似.不幸的是沒有可用的線程,隻是日志中的wicket警告)
2016-03-10 15:00:39,009 WARN [http-xxx:7443-23] org.apache.wicket.page.PageAccessSynchronizer: Thread 'http-xxx:7443-23' Failed to acquire lock to page with id '28',attempted for 3 minutes out of allowed 3 minutes. The thread that holds the lock has name 'http-xxx:7443-18'.
2016-03-10 15:00:39,017 WARN [http-xxx:7443-23] org.apache.wicket.page.PageAccessSynchronizer: "http-xxx:7443-18" daemon prio=5 tid=8950 state=RUNNABLE
org.apache.wicket.util.lang.Threads$ThreadDump
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
at java.lang.Class.getConstructor0(Class.java:2895)
at java.lang.Class.newInstance(Class.java:354)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:113)
at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:331)
at java.io.ObjectStreamClass.getSerializableConstructor(ObjectStreamClass.java:1376)
at java.io.ObjectStreamClass.access$1500(ObjectStreamClass.java:72)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:493)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:468)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.(ObjectStreamClass.java:468)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:365)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1133)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
[application code]
2016-03-10 15:04:14,640 WARN [http-xxx:7443-16] org.apache.wicket.page.PageAccessSynchronizer: Thread 'http-xxx:7443-16' Failed to acquire lock to page with id '11',attempted for 3 minutes out of allowed 3 minutes. The thread that holds the lock has name 'http-xxx:7443-38'.
2016-03-10 15:04:14,642 WARN [http-xxx:7443-16] org.apache.wicket.page.PageAccessSynchronizer: "http-xxx:7443-38" daemon prio=5 tid=9088 state=RUNNABLE
org.apache.wicket.util.lang.Threads$ThreadDump
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
at java.lang.Class.getConstructor0(Class.java:2895)
at java.lang.Class.newInstance(Class.java:354)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
at sun.reflect.MethodAccessorGenerator.generateMethod(MethodAccessorGenerator.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:46)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
[application code]
我們目前無法重制這一點(仍在努力).但也許社群中的某些人已經看到了類似的東西,并且知道什麼可以幫助我們重制或解決問題.
我們目前的一個猜測是,這與本機記憶體消耗有關(因為像http://www.ibm.com/developerworks/java/library/j-nativememory-linux/這樣的資訊)但我們在日志中沒有看到這方面的任何提示(沒有OutOfMemory錯誤,沒有來自linux管理者的報告說系統記憶體不足)