简体   繁体   English

Quartz.Net-死锁

[英]Quartz.Net - Deadlocking

I'm working on a scheduler which checks every 30 seconds database for any changes in survey table. 我正在使用一个调度程序,该程序每30秒检查一次数据库,以查看调查表中的任何更改。 Survey table contains fields such as Name, WhenDue (for simplicity). 调查表包含诸如名称,WhenDue(为简单起见)之类的字段。

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. 这是我的逐步操作-我实际上使用Quartz Job,该设置设置为每30秒触发一次以添加更多作业。

  • 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. 看起来这是一个SQL异常,Quartz只是将其传递到堆栈中。 Try selecting your data with NOLOCK option: 尝试使用NOLOCK选项选择数据:

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

Google for more info on NOLOCK. Google以获得有关NOLOCK的更多信息。 Most likely you need to redesign your database schema or live with NOLOCKs (not necessarily a bad thing). 您很可能需要重新设计数据库架构或使用NOLOCK(不一定是一件坏事)。

I believe this is a known issue with Quartz.Net when you use the ADO Job Store. 我相信当您使用ADO Job Store时,这是Quartz.Net的已知问题。 There are some suggestions that seem to mitigate the problem, like using UpdateLockRowSemaphore with SQLServer or moving your adojobstore to a separate database. 有一些建议似乎可以缓解该问题,例如将UpdateLockRowSemaphore与SQLServer一起使用或将adojobstore移至单独的数据库。

Here are the threads from the google groups mailing list that discuss the issue. 下面是线程从谷歌网上论坛邮寄列表中讨论这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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