activemq-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erich Duda (JIRA)" <>
Subject [jira] [Created] (ARTEMIS-968) Synchronization issue in ActiveMQThreadPoolExecutor
Date Wed, 15 Feb 2017 13:54:41 GMT
Erich Duda created ARTEMIS-968:

             Summary: Synchronization issue in ActiveMQThreadPoolExecutor
                 Key: ARTEMIS-968
             Project: ActiveMQ Artemis
          Issue Type: Bug
          Components: Broker
    Affects Versions: 1.5.2, 2.0.0
            Reporter: Erich Duda

During investigation of test failures in Artemis test suite I've noticed that ActiveMQThreadPoolExecutorTest
sometimes doesn't allocate new Worker for a task even if {{maxPoolSize = 16}} and there are
only 3 tasks to execute. Instead the task is queued and it waits until some worker finishes
its job.

I think the problem is in offer method.

public boolean offer(Runnable runnable) {
  int poolSize = executor.getPoolSize();

  // If the are less threads than the configured maximum, then the tasks is
  // only queued if there are some idle threads that can run that tasks.
  // We have to add the queue size, since some tasks might just have been queued
  // but not yet taken by an idle thread.
  if (poolSize < executor.getMaximumPoolSize() && (size() + executor.getActive())
>= poolSize)
    return false;

  return super.offer(runnable);

There are 3 variables which are compared with themselves - {{executor.getPoolSize()}}, {{size()}},
{{executor.getActive()}} - without any synchronization. It may happen that the if condition
is {{false}} just because some variable hasn't been updated yet.

I've created reproducer \[1\] for this issue. You can run it from branch \[2\] using following

git clone
cd activemq-artemis
git checkout ActiveMQThreadPoolExecutorTest

mvn test -Dtest=ActiveMQThreadPoolExecutorTest -Ptests -DfailIfNoTests=false -Drat.ignoreErrors=true
2>&1 | tee log


This message was sent by Atlassian JIRA

View raw message