Hi all.
I have a basic setup of two jobs, one with DisallowConcurrentExecution attribute and one without.
The job without that attribute triggers as expected and gets it's Execute method called on time.
However, the job with DisallowConcurrentExecution gets called every 30+ seconds (and it's a simple trigger set to fire every 8 seconds). In DB it's TIMES_TRIGGERED column does get incremented more frequently, however the Execute Method doesnt get called. All works just fine when using RAM jobstore.
Jobstore is setup for ADO on SqlServer 2012 with these (and other) config values:
quartz.jobStore.type = Quartz.Impl.AdoJobStore.JobStoreTX, Quartz
quartz.jobStore.driverDelegateType = Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz
quartz.jobStore.useProperties = false
quartz.dataSource.default.provider = SqlServer-20
#quartz.jobStore.lockHandler.type = Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz
quartz.jobStore.clustered = false
#quartz.jobStore.acquireTriggersWithinLock = true
I did try setting the lockHandler.type and acquireTriggersWithinLock the but it gave no result (trigger/job still gets his second Execute called on ~30 second mark instead of 8 second mark).
Basically, second (and all other) Execute's get called much later than scheduled but all the values in DB seem to be ok regarding REPEAT_INTERVAL and related columns.
I wouldnt expect DB to be the bottleneck here (its just 2 jobs, each with one simple trigger that hits every 8 seconds).
Quick check of SqlServer's Profiler shows nothing wrong there (all queries seem to run fast) and I have set a JobListener which shows that as soon as each Execute gets called so does the JobWasExecuted.
I'm using the latest nuget package.
Let me know if you need more info regarding this that can help locate/fix the problem.
Thanks
class Program
{
static void Main(string[] args)
{
RunProgram(GetMongoFactory()).GetAwaiter().GetResult();
}
private static ISchedulerFactory GetMongoFactory()
{
var properties = new NameValueCollection();
properties[StdSchedulerFactory.PropertySchedulerInstanceName] = typeof(quartzmongo_app.Program).AssemblyQualifiedName;
properties[StdSchedulerFactory.PropertySchedulerInstanceId] = $"{Environment.MachineName}-{Guid.NewGuid()}";
properties[StdSchedulerFactory.PropertyJobStoreType] = typeof(MongoDbJobStore).AssemblyQualifiedName;
// I treat the database in the connection string as the one you want to connect to
properties[$"{StdSchedulerFactory.PropertyJobStorePrefix}.{StdSchedulerFactory.PropertyDataSourceConnectionString}"] = "mongodb://localhost/quartz";
// The prefix is optional
properties[$"{StdSchedulerFactory.PropertyJobStorePrefix}.collectionPrefix"] = "prefix";
properties["quartz.serializer.type"] = "binary";
return new StdSchedulerFactory(properties);
}
private static async Task RunProgram(ISchedulerFactory factory)
{
try
{
// Grab the Scheduler instance from the Factory
IScheduler scheduler = await factory.GetScheduler();
// and start it off
await scheduler.Start();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1", "group1")
.Build();
// Trigger the job to run now, and then repeat every 10 seconds
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(2)
.RepeatForever())
.Build();
await scheduler.DeleteJob(job.Key);
await scheduler.ScheduleJob(job, trigger);
// some sleep to show what's happening
await Task.Delay(TimeSpan.FromSeconds(180));
// and last shut down the scheduler when you are ready to close your program
await scheduler.Shutdown();
}
catch (SchedulerException se)
{
await Console.Error.WriteLineAsync(se.ToString());
}
}
}
[DisallowConcurrentExecution]
public class HelloJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
await Console.Out.WriteLineAsync("Greetings from HelloJob! " + DateTime.UtcNow.ToString());
}
}Greetings from HelloJob! 2018-10-12 6:19:02 PM
Greetings from HelloJob! 2018-10-12 6:19:04 PM
Greetings from HelloJob! 2018-10-12 6:19:28 PM
Greetings from HelloJob! 2018-10-12 6:19:52 PM
Greetings from HelloJob! 2018-10-12 6:21:03 PM
Greetings from HelloJob! 2018-10-12 6:21:32 PM
Greetings from HelloJob! 2018-10-12 6:21:58 PM
typeof(MongoDbJobStore).AssemblyQualifiedName'.This is taken from the nuget package 'Quartz.Spi.MongoDbJobStore' which comes from the following github repo: https://github.com/chrisdrobison/mongodb-quartz-netI wonder if this issue is somehow related. https://github.com/quartznet/quartznet/issues/686