quartz集群報錯but has failed to stop it. This is very likely to create a memory leak.


quartz集群報錯but has failed to stop it. This is very likely to create a memory leak.

在一台配置1核2G內存的阿里雲服務器上運行quartz;執行定時任務報如下異常,而在本地開發環境中則正常運行。


10-Sep-2016 11:43:50.415 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [faxian] appears to have started a thread named [logback-1] 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.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 java.lang.Thread.run(Thread.java:745)
10-Sep-2016 11:43:50.415 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [faxian] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
10-Sep-2016 11:43:50.416 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [faxian] appears to have started a thread named [clusterQuartzScheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
10-Sep-2016 11:43:50.417 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [faxian] appears to have started a thread named [clusterQuartzScheduler_Worker-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)

根據異常,初步判斷是內存溢出導致的問題。查看服務器內存使用情況


 [root@test-server logs]#  free -h
              total       used       free     shared    buffers     cached
 Mem:          1.8G       1.7G       84M       9.4M       154M       520M
 -/+ buffers/cache:       1.1G       759M
 Swap:           0B         0B         0B
 

於是查看quartz的配置


<task:executor id="quartzTaskExecutor" keep-alive="900" pool-size="10" queue-capacity="20" />

pool-size="10",queue-capacity="20"。

然而根據實際情況並,連接池數量和容量並不需要這么大。改成pool-size="1"queue-capacity="1",再次啟動不再報錯。

查看服務器內存使用情況


[root@test-server logs]#  free -h
             total       used       free     shared    buffers     cached
Mem:          1.8G       1.7G       141M       9.3M       154M       422M
-/+ buffers/cache:       1.1G       718M
Swap:           0B         0B         0B


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM