简体   繁体   中英

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

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