Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz org.quartz.jobStore.selectWithLockSQL row lock

I am using Quartz in clustered mode

I have some row lock contention on DB level caused by excessive call to :

org.quartz.jobStore.selectWithLockSQL

"SELECT * FROM QRTZ_LOCKS WHERE SCHED_NAME = :"SYS_B_0" AND LOCK_NAME = :1 FOR UPDATE"

I read quartz docs and is still not very clear to me why is above query is executed.

What is the purpose of having this row lock ?

Regards

like image 617
Cris Avatar asked Oct 21 '14 14:10

Cris


1 Answers

The locks table is used by quartz for coordinating multiple schedulers when deployed in cluster mode. In a cluster only one node should fire the trigger, so a lock is used to avoid multiple nodes acquiring the same trigger.

From the clustering section of the documentation (http://quartz-scheduler.org/generated/2.2.1/html/qs-all/#page/Quartz_Scheduler_Documentation_Set%2Fre-cls_cluster_configuration.html%23):

Clustering currently only works with the JDBC-Jobstore (JobStoreTX or JobStoreCMT), and essentially works by having each node of the cluster share the same database. Load-balancing occurs automatically, with each node of the cluster firing jobs as quickly as it can. When a trigger's firing time occurs, the first node to acquire it (by placing a lock on it) is the node that will fire it.

like image 88
Marios Avatar answered Oct 21 '22 05:10

Marios