Re: Jobs with DisallowConcurrentExecution not executing on scheduled time for ADO jobstore

2,566 views
Skip to first unread message

Sam Sippe

unread,
Jul 3, 2013, 10:56:46 PM7/3/13
to quar...@googlegroups.com
I'm seeing the same behaviour using the mysql AdoJobStore.


On Sunday, March 10, 2013 3:30:39 PM UTC+10, balca wrote:
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

Sam Sippe

unread,
Jul 4, 2013, 12:08:40 AM7/4/13
to quar...@googlegroups.com
Here's full description of the scenario I'm experiencing that sounds like the same issue as the OP.

Marko Lahma

unread,
Mar 30, 2014, 1:31:28 PM3/30/14
to quar...@googlegroups.com

This issue has been fixed in version 2.2.3.

-Marko

Jean-Francois Lavoie

unread,
Oct 12, 2018, 1:05:21 PM10/12/18
to Quartz.NET
Hi, I am using quartz.net 3.0.7 on .net framework 4.7.1 and experience the same behavior. Is it possible a regression was introduced as part of the 3.* release of quartz.net?

Marko Lahma

unread,
Oct 12, 2018, 1:08:05 PM10/12/18
to Quartz. NET
Honestly, it's been five years since this thing happened and I don't
have much recollection. If you have time to investigate relevant
commits and debug what's happening it would be really helpful. It's
crucial to know the exact trigger and job setup.

-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.

Jean-Francois Lavoie

unread,
Oct 12, 2018, 2:26:51 PM10/12/18
to Quartz.NET
 Hi,

you are right. I should have provided those details on my first post in this thread:


Here is the code:
   
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());
       
}
   
}




Here's an ouput sample:
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


As you may have notice, I am using the a job store type of '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-net

Could it be that the nuget package is badly implemented? Or is it from the internals of Quartz.net? I am looking for some guidance of where to start looking to identify this bug.

Thank you.

Marko Lahma

unread,
Oct 13, 2018, 3:03:18 AM10/13/18
to Quartz. NET
Thanks for the details. I found the original fix here:

https://github.com/quartznet/quartznet/commit/5caac8ff713d78f29956867751a5e3acdf2c2def

And looking at the store implementation here:

https://github.com/chrisdrobison/mongodb-quartz-net/blob/master/src/Quartz.Spi.MongoDbJobStore/MongoDbJobStore.cs

It seems that the fix is in place. As this is a whole different job
store I guess it would be best investigated on their side by creating
a corresponding GitHub issue. I haven't used neither Mongo nor the job
store so I'm of limited help here.

-Marko

artl...@gmail.com

unread,
Oct 14, 2018, 3:15:25 AM10/14/18
to Quartz.NET
I wonder if this issue is somehow related. https://github.com/quartznet/quartznet/issues/686
This is the configuration I'm working with:

            NameValueCollection props = new NameValueCollection
                {
                    { "quartz.serializer.type", "binary" },
                    { "quartz.scheduler.instanceId", "AUTO" },
                    { "quartz.jobStore.clustered", "true" },
                    { "quartz.jobStore.type", "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" },
                    { "quartz.jobStore.driverDelegateType", "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" },
                    { "quartz.jobStore.tablePrefix", "QRTZ_" },
                    { "quartz.dataSource.myDS.connectionString", @"***" },
                    { "quartz.dataSource.myDS.provider", "SqlServer" },
                    { "quartz.jobStore.dataSource", "myDS" },
                }; 
 
Reply all
Reply to author
Forward
0 new messages