Quartz Scheduler stops firing tasks at random intervals

632 views
Skip to first unread message

Keith Shimp

unread,
Jul 10, 2018, 1:56:58 PM7/10/18
to Quartz.NET
Current version : 3.0.6
Current .NET framework : .NET Framework 4.6.2

Issue: Scheduler stops at random intervals and discontinues scheduler - Must restart app pool to re-initiate / build task triggers to continue running jobs.

Our system currently uses around 30 background tasks at different times, from every minute to once a month.  We have tried using the simple schedule, DailyTimeInterval schedule, and crons.

Here are some examples of the code we use in each iteration:


This wrapper function builds all of our tasks by type and trigger:
private static async Task ScheduleAsync(BackgroundTaskType type, ITrigger trigger)
{
var jobKey = JobKey.Create(type.ToString());
var job = JobBuilder.Create<QuartzJob>().WithIdentity(jobKey).Build();
ReschedulableJobs.Add(type, job);
scheduler.ScheduleJob(job, trigger);
}
Simple: 
await Schedule(BackgroundTaskType.HelloWorld,
TriggerBuilder.Create()
.WithSimpleSchedule(x => x.WithIntervalInMinutes(6).RepeatForever()).StartNow().Build()
);
DailyTimeInterval: 
await ScheduleAsync(BackgroundTaskType.TheTask,
TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule(
x => x.WithIntervalInMinutes(60)
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 0)) // midnight central
.InTimeZone(TimeZoneInfo.Local)
).Build());
Cron:
await ScheduleAsync(BackgroundTaskType.TheTask,
TriggerBuilder.Create()
.WithCronSchedule("0 0 12 * * ?")
.Build()); // fire every day at noon

await scheduler.Start();

Currently, the simple schedule will fire when we want it to without issue, but on deploy it will fire multiple of each task simultaneously - and because the schedule is based on time since deploy, the actual run times can be
erratic and unpredictables - not what we want.  So that brought us to the daily time interval schedule, which gave us exactly what we wanted, however, the scheduler would randomly stop firing tasks - assuming this is due to some
sort of deadlock somewhere.  We don't get any exceptions, any warnings, nothing.  All that happens is, tasks will cease to fire, and we will need to restart the app pool.  This is a huge issue for us, and the only workaround
that we have found is by writing an application to restart the app pool after 15 minutes of no tasks running.  Obviously not ideal.

Crons will not fire at all with our current implementation.  That was our last hope at getting some consistency.

Right now the issue is that we would like to deviate from simple scheduling BUT ALSO would like our scheduler to be consistent and run 24/7 without any hiccups.  The hangup with tasks ceasing to fire is a huge deterrent to this.

Extra question:
Is this due to all tasks being async? (We used to run with mostly simple scheduler w/o async code.)

Thanks in advance,

Marko Lahma

unread,
Jul 11, 2018, 3:40:40 AM7/11/18
to Quartz. NET
How do you host your application? What version of IIS, is always on
mode used? Where do you start your scheduler - Application_Start? Do
you have handle for scheduler kept as global static variable?

https://www.quartz-scheduler.net/documentation/faq.html#quartz-in-web-environment

-Marko
> --
> You received this message because you are subscribed to the Google Groups "Quartz.NET" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to quartznet+...@googlegroups.com.
> To post to this group, send email to quar...@googlegroups.com.
> Visit this group at https://groups.google.com/group/quartznet.
> For more options, visit https://groups.google.com/d/optout.

Keith Barrows

unread,
Sep 7, 2019, 12:09:33 AM9/7/19
to Quartz.NET

2019-09-06_1500.png

Log entries showing the jobs stopping...
> To unsubscribe from this group and stop receiving emails from it, send an email to quar...@googlegroups.com.

Keith Barrows

unread,
Sep 7, 2019, 12:09:33 AM9/7/19
to Quartz.NET
I am running into the same challenge.  Hosting is via Azure App Service, startup is in the Startup.cs file (MVC+API Core 2.2 app), scheduler is in the DI container (standard MS).  After somewhere between 2 and 4 hours, the one job that is supposed to run every 30s just quits.  It is not due to a shutdown of the web service as everything else is ticking along and we have an average of 20 requests per minute during this time frame.

Is there a way to monitor the heartbeat (job firings) and restart the scheduler when it stops? 
Reply all
Reply to author
Forward
0 new messages