Multiple triggers for a single job detail execute concurrently for a job annotated with @DisallowConcurrentExecution when the triggers are scheduled for the same time and the scheduler is in a cluster.
2023-02-01 15:27:42 INFO [com.tst.MyJob]] (MyJob_Worker-1) start
Cluster Host 2
nothing
database
SCHED_NAME
JOB_NAME
JOB_GROUP
JOB_CLASS_NAME
IS_DURABLE
IS_CONCURRENT
IS_UPDATE_DATA
REQUESTS_RECOVERY
The job will execute concurrently across the cluster
Cluster Host 1
2023-02-01 15:27:42 INFO [com.tst.MyJob]] (MyJob_Worker-1) start
Cluster Host 2
2023-02-01 15:27:52 INFO [com.tst.MyJob]] (MyJob_Worker-5) start
database
SCHED_NAME
JOB_NAME
JOB_GROUP
JOB_CLASS_NAME
IS_DURABLE
IS_CONCURRENT
IS_UPDATE_DATA
REQUESTS_RECOVERY
@Scheduled(cron = "{my.job.cron.expr}", identity = "myJobTest",
concurrentExecution = Scheduled.ConcurrentExecution.SKIP)
public void myJobTest() throws Exception {
logger.infov("start");
Thread.sleep(30000);
logger.infov("end");
Quartz configuration
quarkus.quartz.clustered=true
quarkus.quartz.store-type=jdbc-tx
quarkus.quartz.instance-name=MyClusteredScheduler
my.job.cron.expr=0/10 * * ? * *
Output of uname -a
or ver
Darwin cab-wsm-0279148 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64 x86_64
Output of java -version
openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment GraalVM CE 21.2.0 (build 11.0.12+6-jvmci-21.2-b08) OpenJDK 64-Bit Server VM GraalVM CE 21.2.0 (build 11.0.12+6-jvmci-21.2-b08, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.11.2
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.8.1
Additional information
old issue is ignored
org.quartz.DisallowConcurrentExecution
has no effect if used on a bean class that declares a @Scheduled
method; it's a Quartz-specific annotation that needs to be used to annotate a org.quartz.Job
implementation class. You would need to use a custom job class (annotated with @DisallowConcurrentExecution
) and schedule it programmatically.
Also note that concurrentExecution = Scheduled.ConcurrentExecution.SKIP
will not work across the cluster either.
The #26062 might be related.
@mkouba is it planned to modification for the annotation Scheduled in order to achieve similar behavior with the custom job class (annotatedwith @DisallowConcurrentExecution)?
It might be implemented in the context of #26062. But there is no plan so far.