History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: QUARTZ-491
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: James House
Reporter: Jasper Rosenberg
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Quartz Scheduler

SimpleThreadPool can lose a runnable

Created: 20/Jul/06 01:45 PM   Updated: 27/Jul/06 09:00 AM
Component/s: Thread Pools
Affects Version/s: 1.6
Fix Version/s: 1.6

File Attachments: 1. Java Source File PriorityExample.java (4 kb)
2. File quartz_priority.properties (0.3 kb)
3. Java Source File TriggerEchoJob.java (2 kb)


Flags: Important


 Description  « Hide
During the QUARTZ-13 work, it looks like the check in runInThread() that waits to make sure the previous next runnable has been assigned a worker thread before assigning the new next runnable has been removed. This leads to a race condition (which I ran into) where a nextRunnable gets overwritten by the next in line before it can be processed.

I think this also means the nextAvail count is not being calculated correctly, because for this overwriting case to have been allowed in my sample app with only one worker thread, it must have thought for both triggers that there was a thread available. (This makes sense with the worker thread being the one to decrement the availCount).

I leave this up to you James what you think will be the best way to handle this case since you are already so familiar with the threadpool and related issues (the availCount tracking means it is more complicated than just adding that original loop back in unfortunately).

I will also attach my test case which revealed the problem (when I ran it under the eclipse debugger). Another easy way to reproduce it presumably is to just put a breakpoint in the worker threads to simulate them being slow...)

 All   Comments   Change History      Sort Order:
James House - [24/Jul/06 11:02 AM ]
DOH!

Jasper Rosenberg - [24/Jul/06 12:03 PM ]
I could be mistaken, but I believe this fix still leaves open a window where nextAvail is off by one when a WorkerThread has not yet claimed the next runnable.

James House - [27/Jul/06 09:00 AM ]
I tightened up the synchronization surrounding updates of availCount