简体   繁体   English

Quartz Scheduler集群时间同步

[英]Quartz Scheduler Cluster Time Sync

I've looked through Quartz documentation and I can't seem to find a definite answer to the question: What happens if I am using Quartz Scheduler in a clustered environment but the machines get out of synch (we would be using JobStoreTX)? 我浏览了Quartz文档,但似乎找不到以下问题的明确答案:如果我在集群环境中使用Quartz Scheduler,但计算机不同步(我们将使用JobStoreTX),会发生什么? Will Quartz fire off multiple jobs? 石英会解雇多个工作吗? Will it only fire one by locking the database row entry? 它只会通过锁定数据库行条目来触发一个吗?

Unfortunately I don't think it's documented, however I believe the results aren't so destructive and erroneous. 不幸的是,我认为它没有记录在案,但是我相信结果并没有那么破坏性和错误。

Each Quartz scheduler instance in the cluster polls the database every few seconds trying to find new jobs to fire (I think by default it searches for all jobs with next scheduled time between now - 30 and now + 60 seconds - but this is irrelevant and depends on configuration). 集群中的每个Quartz调度程序实例每隔几秒钟轮询一次数据库,以尝试查找要触发的新作业(我认为默认情况下,它将搜索下一个计划的时间, now - 30秒和now + 60秒之间的所有作业-但这无关紧要,并且取决于在配置上)。 This operation is obviously safe across cluster because it is very likely that multiple instances are polling for new jobs at the same time. 显然,此操作在整个群集中都是安全的,因为很可能多个实例同时轮询新作业。

If server times aren't synchronized across cluster, assume one of the servers has the clock in the future. 如果服务器时间在整个群集中不同步,则假设其中一台服务器将来有时钟。 This server thinks it is later than it actually is so it fetches and starts jobs too early - or at least earlier than all the others. 该服务器认为它晚于实际时间,因此它太早获取或启动作业-至少比所有其他作业早。 This means that a single server will run more if not all jobs, stealing work from the rest of the cluster. 这意味着一台服务器将运行更多(甚至不是全部)作业,从而从集群的其余部分窃取工作。 This is not unsafe per se , but will cause asymmetric cluster load. 本身并不安全,但是会导致群集负载不对称。

I was considering raising an issue suggesting using of database time in all servers to avoid these problems. 我正在考虑提出一个问题,建议在所有服务器中使用数据库时间来避免这些问题。 However the popularity of and added complexity of using external time source makes it a bad idea. 但是, 的普及以及使用外部时间源的复杂性使其成为一个坏主意。

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

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