Davita
Davita

Reputation: 9114

Quartz.NET and Deadlocks

I'm playing with latest version of Quartz.NET. I'm using AdoJobStore (with SqlServer-20 delegate) to store my jobs. I create new jobs this way:

        JobDetail jobDetail = new JobDetail("myJob", null, typeof(HelloJob));
        jobDetail.JobDataMap["dsa"] = "hello";
        CronTrigger trigger = new CronTrigger("MyTrigger", null, "0/1 * * * * ?");
        trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow.AddMonths(-3));
        trigger.Name = "MyTrigger";
        sched.ScheduleJob(jobDetail, trigger);

// another job

JobDetail jobDetail = new JobDetail("myJob_Bye", null, typeof(HelloJob));
jobDetail.JobDataMap["dsa"] = "Good Bye";
CronTrigger trigger = new CronTrigger("MyTrigger", null, "0/2 * * * * ?");
trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow.AddMonths(-3));
trigger.Name = "MyTrigger2";
sched.ScheduleJob(jobDetail, trigger);

The problem is that when I start the scheduler, it works for some (triggers jobs configured above) time and then throws SqlException with message "Transaction (Process ID 53) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.". The error occures in JobStoreSupport.cs, line 4217. Looks like there's a problem with lock handling. Anyone has any idea how can I solve this issue.

P.S. This quartz assembly is my custom build i'm playing with. I just changed table and column names in AdoConstants.cs and corresponding .sql file.

Thanks for your support

Upvotes: 0

Views: 1354

Answers (1)

Davita
Davita

Reputation: 9114

I found out what was wrong. Looks like when using SQL Server, you shouldn't use varchar datatype. Quartz.NET has some problems with it. Instead, switch to nvarchar and the problem will be fixed.

Upvotes: 1

Related Questions