Reputation: 2846
I am using Quartz.net in mono. When I create a scheduler like this:
ISchedulerFactory quartzSchedulerFactory = new StdSchedulerFactory();
IScheduler quartzScheduler = quartzSchedulerFactory.GetScheduler();
in Quartz.Net, in the class SimpleThreadPool the following method is called:
/// <summary>
/// Called by the QuartzScheduler before the <see cref="ThreadPool" /> is
/// used, in order to give the it a chance to Initialize.
/// </summary>
public virtual void Initialize()
{
if (workers != null && workers.Count > 0)
{
// already initialized...
return;
}
if (count <= 0)
{
throw new SchedulerConfigException("Thread count must be > 0");
}
// create the worker threads and start them
foreach (WorkerThread wt in CreateWorkerThreads(count))
{
wt.Start();
availWorkers.AddLast(wt);
}
}
In Windows this works fine, but in CentOS the system freezes when wt.Start() is called. Even if I kill the process it becomes defunct and only restarting the system can kill it. Although sometimes it works, about one in 5 times I execute the program.
Here is the code called when the WorkerThread starts:
public override void Run()
{
bool ran = false;
bool shouldRun;
lock (this)
{
shouldRun = run;
}
while (shouldRun)
{
try
{
lock (this)
{
while (runnable == null && run)
{
Monitor.Wait(this, 500);
}
if (runnable != null)
{
ran = true;
runnable.Run();
}
}
}
catch (Exception exceptionInRunnable)
{
log.Error("Error while executing the Runnable: ", exceptionInRunnable);
}
finally
{
lock (this)
{
runnable = null;
}
// repair the thread in case the runnable mucked it up...
if (Priority != tp.ThreadPriority)
{
Priority = tp.ThreadPriority;
}
if (runOnce)
{
lock (this)
{
run = false;
}
tp.ClearFromBusyWorkersList(this);
}
else if (ran)
{
ran = false;
tp.MakeAvailable(this);
}
}
// read value of run within synchronized block to be
// sure of its value
lock (this)
{
shouldRun = run;
}
}
log.Debug("WorkerThread is shut down");
}
Could it be a deadlock problem? And if it is, why doesn't it happen in windows?
Thanks
Upvotes: 1
Views: 1082
Reputation: 64
I had the similar issue in the CentOs. Mono 2.10.8.1 was stuck at creating default threadpool threads. After the stuck it was impossible to kill the process or get the stacktrace.
I've managed to fix the problem by updating the core of the OS. From 2.6.32-71.el6.x86_64 up to 2.6.32-279.14.1.el6.x86_64.
Upvotes: 3