Quartz Timer Cluster Time Synchronization

I've looked at the Quartz documentation and I can't seem to find a definite answer to the question: What happens if I use Quartz Scheduler in a clustered environment, but the machines crash (we'll be using JobStoreTX)? Will quartz lay off multiple jobs? Will it only run one, blocking the write of the database row?

+3


source to share


1 answer


Unfortunately, I do not think this is documented, however, I believe that the results are not so destructive and erroneous.

Each Quartz scheduler instance in the cluster scans the database every few seconds, trying to find new jobs to start (I think by default it looks for all jobs with the next scheduled time between now - 30

and now + 60

seconds - but that doesn't matter and depends on the configuration). This operation is obviously safe for the cluster because it is very likely that multiple instances of polling for new jobs at the same time.



If the server time is not synchronized between clusters, assume that one of the servers will have a clock in the future. This server thinks it is later than it actually is, so it picks and starts jobs too early - or at least earlier than everyone else. This means that more if not all jobs will run on one server and sneak out of the rest of the cluster. This is unsafe as such, but will result in asymmetric load on the cluster.

I was considering raising the issue of using database time across all servers to avoid these issues. However, the popularity and the added complexity of using an external time source makes it bad.

+1


source







All Articles