gpt4 book ai didi

spring - Quartz org.quartz.jobStore.selectWithLockSQL 行锁

转载 作者:IT老高 更新时间:2023-10-28 13:47:28 24 4
gpt4 key购买 nike

我在集群模式下使用 Quartz

由于过度调用,我在 DB 级别存在一些行锁争用:

org.quartz.jobStore.selectWithLockSQL

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

我阅读了 quartz 文档,但我仍然不太清楚为什么执行上述查询。

拥有这个行锁的目的是什么?

问候

最佳答案

在集群模式下部署时,quartz 使用锁表来协调多个调度程序。在集群中只有一个节点应该触发触发器,因此使用锁来避免多个节点获取相同的触发器。

来自文档的集群部分 (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.

关于spring - Quartz org.quartz.jobStore.selectWithLockSQL 行锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26489301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com