Tomcat進程异常退出的一次記錄

mb5fd8680e223c2 2021-09-18 10:03:52 阅读数:155

tomcat 异常 退出 一次


問題描述:

聯調過程中,某Tomcat進程發現進程掛了,查看日志發現

16-Jul-2021 17:44:35.264 INFO [Thread-8] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-80"]

16-Jul-2021 17:44:35.271 INFO [Thread-8] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]

[INFO ] 2021-07-16 17:44:35.290 [Curator-Framework-0]-[CuratorFrameworkImpl.java:821] - backgroundOperationsLoop exiting

[INFO ] 2021-07-16 17:44:35.294 [Thread-6]-[ZooKeeper.java:684] - Session: 0x10046c488240ac3 closed

[INFO ] 2021-07-16 17:44:35.294 [main-EventThread]-[ClientCnxn.java:512] - EventThread shut down

[INFO ] 2021-07-16 17:44:35.316 [Thread-6]-[ConnectionListener.java:22] - RabbitMQ連接關閉:[email protected]caae

[INFO ] 2021-07-16 17:44:35.339 [Thread-6]-[ExecutorConfigurationSupport.java:208] - Shutting down ExecutorService

16-Jul-2021 17:44:35.352 WARNING [Thread-8] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

16-Jul-2021 17:44:35.352 WARNING [Thread-8] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

16-Jul-2021 17:44:35.353 WARNING [Thread-8] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [Curator-ConnectionStateManager-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:

sun.misc.Unsafe.park(Native Method)

java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)

java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)

java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:403)

org.apache.curator.framework.state.ConnectionStateManager.processEvents(ConnectionStateManager.java:245)

org.apache.curator.framework.state.ConnectionStateManager.access$000(ConnectionStateManager.java:43)

org.apache.curator.framework.state.ConnectionStateManager$1.call(ConnectionStateManager.java:111)

java.util.concurrent.FutureTask.run(FutureTask.java:266)

java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

java.lang.Thread.run(Thread.java:745)

 

再往上翻,並沒有异常的日志,服務在17:44:35.264這個時間點之前運行很正常,進程是"突然"關閉的,而且日志中還打印有關閉的信息。查看機器內存占用也非常樂觀,不是因為內存占滿而導致的關閉。

 

解决:在一番摸索及百度下發現了關閉的原因-脚本啟動進程後shell關閉引起。

shell脚本如下:

Tomcat進程异常退出的一次記錄_java

 

 最後是通過tail命令監聽了日志,tomcat啟動為後,當前shell進程並沒有退出,而是掛住在tail進程,往終端輸出日志內容。這種情况下,如果用戶直接關閉ssh終端的窗口(用鼠標或快捷鍵),則java進程也會退出。而如果先ctrl-c終止脚本sh進程,然後再關閉ssh終端的話,則java進程不會退出。

問題可以複現,最後修改了脚本解决。

 


版权声明:本文为[mb5fd8680e223c2]所创,转载请带上原文链接,感谢。 https://gsmany.com/2021/09/20210918100351900x.html