システムについて知識が浅いため、必要な情報が足りない可能性もあります。
他に必要な情報があれば提示させていただきますのでご指摘ください。
前提・実現したいこと
java、spring mvc、apache poiを使用してwebアプリでExcel出力の処理を実装しています。
Excel出力を何度か行うとリクエストの応答がなくなります。
(画面は読み込み中となり、おそらくExcelの処理まで到達していない)
自分なりに調査した結果、スレッドリークしているのではないかと予想しています。
理由としましては、処理を度にスレッドダンプにwaitのログが吐かれていたため。
スレッドリークの場合、どいういった箇所に注意すればよいか、
また原因が違う場合はどういった対処が必要かを教えていただきたいです。
発生している問題・エラーメッセージ
現象が発生した際のtomcatのスレッドダンプとなります。
文字数制限のため、関係がありそうな箇所の抜粋となります。
2018-02-23 12:50:40
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.121-b13 mixed mode):"ajp-nio-8009-exec-10" #36 daemon prio=5 os_prio=0 tid=0x000000001c096800 nid=0x1e7c waiting on condition [0x0000000028b2f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000008e9bd420> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:103)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:31)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)"ajp-nio-8009-exec-9" #35 daemon prio=5 os_prio=0 tid=0x000000001c096000 nid=0x1a98 waiting on condition [0x0000000028a2f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000008e9bd420> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:103)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:31)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)"ajp-nio-8009-exec-8" #34 daemon prio=5 os_prio=0 tid=0x000000001c095000 nid=0xf70 waiting on condition [0x000000002892f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000008e9bd420> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:103)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:31)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)"ajp-nio-8009-exec-7" #33 daemon prio=5 os_prio=0 tid=0x000000001c091800 nid=0x10f8 waiting on condition [0x000000002882f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000008e9bd420> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:103)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:31)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
==============================
■■■以下がtomcatのログです。■■■
[2018-02-23 17:04:44,731] [ERROR] localhost-startStop-2 org.apache.catalina.loader.WebappClassLoaderBase - The web application [XXX] created a ThreadLocal with key of type [com.microsoft.sqlserver.jdbc.ActivityCorrelator$1] (value [com.microsoft.sqlserver.jdbc.ActivityCorrelator$1@43b494c4]) and a value of type [com.microsoft.sqlserver.jdbc.ActivityId] (value [06408c05-b19c-4b0b-b710-17f80bc9dfde-43]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
[2018-02-23 17:04:44,731] [ERROR] localhost-startStop-2 org.apache.catalina.loader.WebappClassLoaderBase - The web application [XXX] created a ThreadLocal with key of type [com.microsoft.sqlserver.jdbc.ActivityCorrelator$1] (value [com.microsoft.sqlserver.jdbc.ActivityCorrelator$1@43b494c4]) and a value of type [com.microsoft.sqlserver.jdbc.ActivityId] (value [06408c05-b19c-4b0b-b710-17f80bc9dfde-43]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
[2018-02-23 17:04:44,732] [ERROR] localhost-startStop-2 org.apache.catalina.loader.WebappClassLoaderBase - The web application [XXX] created a ThreadLocal with key of type [com.microsoft.sqlserver.jdbc.ActivityCorrelator$1] (value [com.microsoft.sqlserver.jdbc.ActivityCorrelator$1@43b494c4]) and a value of type [com.microsoft.sqlserver.jdbc.ActivityId] (value [c3609dbd-95ec-45d0-9695-c5c3f2624883-17]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
[2018-02-23 17:04:44,732] [ERROR] localhost-startStop-2 org.apache.catalina.loader.WebappClassLoaderBase - The web application [XXX] created a ThreadLocal with key of type [com.microsoft.sqlserver.jdbc.ActivityCorrelator$1] (value [com.microsoft.sqlserver.jdbc.ActivityCorrelator$1@43b494c4]) and a value of type [com.microsoft.sqlserver.jdbc.ActivityId] (value [c3609dbd-95ec-45d0-9695-c5c3f2624883-17]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
該当のソースコード
java,spring mvc
ソースコードは現在手元になく、提示できません。
スレッドに関係しそうな処理としては、以下のような処理ですが、処理の中でマルチスレッドにはしていません。
while (条件式){
Thread.sleep(3000)
}
試したこと
特になし。
補足情報(FW/ツールのバージョンなど)
Java 8 Update 121
Apache2.4.29
Tomcat8.0.36
(組み込みtomcatではありません)
spring framework 4.3.6
spring mvcを使用。spring bootではありません。
回答1件
あなたの回答
tips
プレビュー