简体   繁体   中英

Quartz.Net - Deadlocking

I'm working on a scheduler which checks every 30 seconds database for any changes in survey table. Survey table contains fields such as Name, WhenDue (for simplicity).

Here is step by step what I do - I actually use Quartz Job which set-up up to trigger every 30 seconds to add more jobs.

  • Load all surveys which have been modified after last pulled date/time
  • Foreach through them and either add new or update existing job/triggers

Program works fine when I first start it, it gets all surveys etc.

However, if i go into survey and change something, my program picks up changes however it throws exception

Quartz.JobPersistenceException: Couldn't acquire next trigger: Couldn't retrieve trigger: Transaction (Process ID 59) was deadlocked on lock resources with another process and has been chosen as the deadlock victim.

This not sure why this could be happening. Any suggestions are welcome, I spend few hours now trying to track it down.

Looks like it's a SQL exception, Quartz just passes it up the stack. Try selecting your data with NOLOCK option:

select dbo.Table.Column
from dbo.Table with(NOLOCK)
where dbo.Table.OtherColumn = @Param;

Google for more info on NOLOCK. Most likely you need to redesign your database schema or live with NOLOCKs (not necessarily a bad thing).

I believe this is a known issue with Quartz.Net when you use the ADO Job Store. There are some suggestions that seem to mitigate the problem, like using UpdateLockRowSemaphore with SQLServer or moving your adojobstore to a separate database.

Here are the threads from the google groups mailing list that discuss the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM