java.lang.IllegalStateException: Timer already cancelled caused by Exception in 
thread "ActiveMQ Scheduler" java.util.ConcurrentModificationException and 
----------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: AMQ-1727
                 URL: https://issues.apache.org/activemq/browse/AMQ-1727
             Project: ActiveMQ
          Issue Type: Bug
          Components: Message Store
    Affects Versions: 5.1.0
            Reporter: Gary Tully


stack trace causes timer thread to abort:

Exception in thread "ActiveMQ Scheduler" 
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:841)
at java.util.HashMap$KeyIterator.next(HashMap.java:877)
at java.util.AbstractSet.removeAll(AbstractSet.java:143)
at 
org.apache.activemq.kaha.impl.async.AsyncDataManager.consolidateDataFilesNotIn(AsyncDataManager.java:404)
at 
org.apache.activemq.store.amq.AMQPersistenceAdapter.cleanup(AMQPersistenceAdapter.java:415)
at 
org.apache.activemq.store.amq.AMQPersistenceAdapter$3.run(AMQPersistenceAdapter.java:267)
at org.apache.activemq.thread.SchedulerTimerTask.run(SchedulerTimerTask.java:33)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

subsequent timer enqueue fails with:

java.lang.IllegalStateException: Timer already cancelled.
at java.util.Timer.sched(Timer.java:354)
at java.util.Timer.scheduleAtFixedRate(Timer.java:296)
at org.apache.activemq.thread.Scheduler.executePeriodically(Scheduler.java:38)
at 
org.apache.activemq.kaha.impl.async.AsyncDataManager.start(AsyncDataManager.java:190)
at 
org.apache.activemq.store.amq.AMQPersistenceAdapter.start(AMQPersistenceAdapter.java:207)
at 
org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:1597)
at 
org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:1550)
at org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:560)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:455)

Problem identified in this diff, the inUse set needs to be copied as it may be 
modified in parallel to the cleanup.

Index: 
activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
===================================================================
--- 
activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
        (revision 655936)
+++ 
activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
        (working copy)
@@ -411,7 +411,7 @@
             }
             Integer lastDataFile = asyncDataManager.getCurrentDataFileId();
             inProgress.add(lastDataFile);
-            Set<Integer> inUse = 
referenceStoreAdapter.getReferenceFileIdsInUse();
+            Set<Integer> inUse = new 
HashSet<Integer>(referenceStoreAdapter.getReferenceFileIdsInUse());
             asyncDataManager.consolidateDataFilesNotIn(inUse, inProgress);
         } catch (IOException e) {
             LOG.error("Could not cleanup data files: " + e, e);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to