Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 325356

Summary: Sometimes the JobManager/WorkerPool takes a long time before starting a Job
Product: [Eclipse Project] Platform Reporter: Jürgen Becker <juergen.becker>
Component: RuntimeAssignee: John Arthorne <john.arthorne>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: cwilliams.work, pwebster, yevshif
Version: 3.6   
Target Milestone: 3.7 M3   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch v01 none

Description Jürgen Becker CLA 2010-09-15 10:23:40 EDT
The setup is the following: We have two Jobs currently executing. They both finish and the Worker (run()) calls "endJob(currentJob, result)" on the WorkerPool.
The first thing the WorkerPool does is to decrement the busyThreads counter (decrementBusyThreads()), which is then "0". Afterwards the JobManager is informed (manager.endJob(job, result, true)). The JobManager sends an event to the listeners (jobListeners.done((Job) job, result, reschedule)). Keep in mind, all this is happening on the two Worker threads, not on the InternalWorker thread.
If now the listeners do not finish for some time (waiting on a lock, user interaction,...), both threads are occupied.
Now we try to schedule a new Job. It will be added to the queue and the WorkerPool gets informed by the JobManager by calling "jobQueued()".
"jobQueued" first checks if there are sleeping threads (no, all are busy) and it then checks if all Worker are occoupied (busyThreadsCounter >= numThreads), which fails too, because the busyThreadsCounter is "0". No new Worker is created and the Job is waiting in the queue. The Job is not executed till one of the listeners finishes.

Most of the time this is not a problem, but an easy fix for the other cases would be to postpone the decrement of the busyThreads counter until the listeners have finished.
Comment 1 John Arthorne CLA 2010-09-28 09:04:35 EDT
Thank you for the detailed analysis!
Comment 2 John Arthorne CLA 2010-10-04 13:33:21 EDT
Created attachment 180186 [details]
Patch v01
Comment 3 John Arthorne CLA 2010-10-06 14:06:11 EDT
Fix released.
Comment 4 John Arthorne CLA 2012-03-23 10:38:51 EDT
*** Bug 375166 has been marked as a duplicate of this bug. ***