Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-19622

PeriodicWork can block timer thread; use ScheduledExecutorService instead

XMLWordPrintable

      A buggy plugin can block the Jenkins timer thread. This will prevent slave provisioning (NodeProvisionerInvoker) from running, among many other problems.

      AsyncPeriodicWork is designed for this purpose and should be used if fast execution cannot be guaranteed. Nonetheless, Jenkins core should defend against plugins with slow tasks (disk I/O, network) which fail to use it and use PeriodicWork instead; or which have an extension which is called from within a core PeriodicWork, such as a Trigger, and fail to spawn a thread for their body.

      It would be better to deprecate Trigger.timer (which unfortunately still leaves a useless TimerThread lying around) and switch to a ScheduledExecutorService, which allows concurrency in case one task has not finished by the time the next is ready to run.

      It would also be useful to have an administrative monitor which reports non-async PeriodicWork implementations that are taking "too long", defined either as still being running when the next task is ready to go, or which are taking more than e.g. 10% of their defined recurrence period, etc.

            recampbell Ryan Campbell
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: