Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-4640

ManagedScheduledExecutorService fails with NPE during concurrent execution of fixed-rate tasks

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • 9.0.0.Final
    • 8.1.0.Final
    • EE
    • None
    • Hide

      This can be reproduced by submitting a simple task (e.g. containing just a log statement) to the service via scheduleAtFixedRate() with a fixed rate of 1 millisecond, or by submitting a task containing a thread.sleep() statement that is equal to or longer than the scheduled fixed rate. Given enough iterations of execution the error seems to occur consistently.

      Show
      This can be reproduced by submitting a simple task (e.g. containing just a log statement) to the service via scheduleAtFixedRate() with a fixed rate of 1 millisecond, or by submitting a task containing a thread.sleep() statement that is equal to or longer than the scheduled fixed rate. Given enough iterations of execution the error seems to occur consistently.
    • Hide

      The problem does not appear to occur when using scheduleWithFixedDelay instead of scheduleAtFixedRate.

      The problem can also be worked around by configuring only a single thread: standalone.xml <managed-scheduled-executor-service core-threads="1">

      Show
      The problem does not appear to occur when using scheduleWithFixedDelay instead of scheduleAtFixedRate. The problem can also be worked around by configuring only a single thread: standalone.xml <managed-scheduled-executor-service core-threads="1">

    Description

      The ManagedScheduledExecutorService can permanently abort a given fixed-rate task if the task is executed by multiple executor threads concurrently.

      The resulting error is:

      SEVERE [org.glassfish.enterprise.concurrent] EE-ManagedScheduledExecutorService-default-Thread-x) java.lang.NullPointerException.

      The error occurs in org.glassfish.enterprise.concurrent.ManagedThreadFactoryImpl.run().

      Once this error occurs, the task will not execute again.

      This is clearly not a typical condition as one would generally expect the ManagedScheduledExecutorService to be used to support tasks where the execution interval is much longer than the time taken to execute the task, thus we would not normally expect multiple threads to execute the task concurrently. However one could imagine conditions under which this might occur, for example if the task execution was slowed by some unusual system load condition. In any case it seems reasonable to expect this condition should fail gracefully in a way that does not permanently prevent all future executions of the scheduled task.

      Note that tasks submitted using scheduleWithFixedDelay do not seem subject to this issue, presumably because the executor service waits for completion of each task and thus does not end up in a concurrent execution situation.

      Attachments

        Activity

          People

            tadamski@redhat.com Tomasz Adamski
            jkranes@mitre.org Jon Kranes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: