我们有一个在Tomcat(8.0.32)上运行的Java应用程序,该应用程序间歇地停止处理请求。 CPU的工作量非常小,线程转储显示的运行线程数量不多,正在等待的线程数量更多(在Tomcat中大多数情况下看起来像排队的线程)。
在我看来,Tomcat工作人员和客户端轮询程序已经陷入困境,但是很可能/很可能是我误读了线程转储。我有一个clientPoller在提供连接到队列时似乎正在等待锁。相同的锁阻止任何工作人员从队列中拾取任何东西。我们看不到任何导致锁的线程。下面是ClientPoller +一个工作程序(许多工作程序具有相同堆栈跟踪)的堆栈跟踪:
"http-nio-8888-ClientPoller-1" #42 daemon prio=5 os_prio=0 tid=0x00007efc9cb86800 nid=0x3367 waiting on condition [0x00007efc5f5f4000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000821e3940> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:209)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285)
at java.util.concurrent.LinkedBlockingQueue.signalNotEmpty(LinkedBlockingQueue.java:172)
at java.util.concurrent.LinkedBlockingQueue.offer(LinkedBlockingQueue.java:430)
at org.apache.tomcat.util.threads.TaskQueue.offer(TaskQueue.java:74)
at org.apache.tomcat.util.threads.TaskQueue.offer(TaskQueue.java:31)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1361)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:163)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:141)
at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:934)
at org.apache.tomcat.util.net.NioEndpoint$Poller.processKey(NioEndpoint.java:834)
at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:810)
at java.lang.Thread.run(Thread.java:745)
"http-nio-8888-exec-1" #46 daemon prio=1 os_prio=0 tid=0x00007efbb8002000 nid=0x336a waiting on condition [0x00007efc5f2f1000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000821e3940> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2083)
at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:85)
at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:31)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1066)
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)
问题:
很高兴在必要时上传整个线程转储,并提供其他信息。
答案 0 :(得分:0)
不再支持Tomcat8.0.x。如果尚未将其添加到您的TODO列表中,则应添加升级到8.5.x或9.0.x的功能-理想情况是两者中的最新版本。
最好的猜测是OutOfMemoryError杀死线程,同时该线程持有其他线程正在等待的锁。从理论上讲,应该已经释放了锁定,但是一旦OOME发生,就无法保证。在此问题发生之前,我会在一段时间内检查您的日志。如果它是OOME,则可能需要运行事件探查器来检查一段时间内的内存使用情况,以防应用程序需要更大的堆。