Jerry Cwiklik created UIMA-5036: ----------------------------------- Summary: UIMA-DUCC: fix Agent RejectedExecutionException Key: UIMA-5036 URL: https://issues.apache.org/jira/browse/UIMA-5036 Project: UIMA Issue Type: Bug Components: DUCC Reporter: Jerry Cwiklik Assignee: Jerry Cwiklik Fix For: future-DUCC
Fix a race condition which leads to RejectedExecutionException in LinuxProcessMetricsProcessor.process() method. The method fails with this stack trace: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@4c38895 rejected from java.util.concurrent.ThreadPoolExecutor@41c10669[Terminated, pool \ size = 0, active threads = 0, queued tasks = 0, completed tasks = 2052] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.uima.ducc.agent.processors.LinuxProcessMetricsProcessor.process(LinuxProcessMetricsProcessor.java:291) at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190) at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:165) at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:73) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) In the above, the thread pool state shows as Terminated when a submit API was called. This means that the thread pool was stopped when the code was trying to use the pool. Each process spawned by an Agent has a Camel driven timer which triggers metrics collection. The metrics are collected in multiple threads provided by the thread pool. The fix is to synchronize code in close() and process() on a common lock. In stop() the code sets a boolean indicating that the metrics collection should not take place. In the process(), the code checks the boolean to determine if it should proceed. The Camel driven timer is eventually stopped in a code handling process termination. -- This message was sent by Atlassian JIRA (v6.3.4#6332)