Quarkus-Quartz: Jobs running concurrently in clustered environment
See original GitHub issueDescribe the bug Hi,
I was using Quarkus/Quartz in my project to manage jobs in a clustered environment. My requirement is that the my job is running exactly once.
Following this guide: https://quarkus.io/guides/scheduler-reference#concurrent_execution my Job method looked like this:
@Scheduled(every = "15s", concurrentExecution = SKIP)
void nonConcurrent() throws Exception {
logger.info("start");
Thread.sleep(30000);
logger.info("end");
}
Running locally, the job was really just executed once. In my cluster, the job was executed exactly once by each pod.
Expected behavior
I expected concurrentExecution = SKIP to make use of the Job configuration parameter is_nonconcurrent which is used by quartz to ensure a job is running nonconcurrently.
Actual behavior
is_nonconcurrent is not set by concurrentExecution = SKIP.
Jobs are actually executed concurrently in a multi-pod environment
To Reproduce
Steps to reproduce the behavior:
- Setup project with quarkus and quartz
- Create the job mentioned above
- Run multiple pods
Configuration Quarkus version: 1.10.5.Final
quarkus:
quartz:
clustered: true
store-type: jdbc_cmt
Environment (please complete the following information):
- Output of
uname -aorver: Darwin Kernel Version 20.2.0 - Output of
java -version: openjdk version “11.0.9” 2020-10-20 - GraalVM version (if different from Java): %
- Quarkus version or git rev: 1.10.5.Final
- Build tool (ie. output of
mvnw --versionorgradlew --version): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec Java version: 15.0.1, vendor: N/A, runtime: /usr/local/Cellar/openjdk/15.0.1/libexec/openjdk.jdk/Contents/Home Default locale: en_DE, platform encoding: US-ASCII OS name: “mac os x”, version: “10.16”, arch: “x86_64”, family: “mac”
Additional context %
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Related StackOverflow Question
Hello, yes the
Scheduled#concurrentExecution()is not reflected in the Quartz cluster config in any way. And the docs intentionally do not mention that it does. Nevertheless, if theis_nonconcurrentcolumn maps to@DisallowConcurrentExecutionI don’t think it would help to prevent multiple job executions in a cluster.In any case, I think that this issue duplicates https://github.com/quarkusio/quarkus/issues/14671 that was fixed in https://github.com/quarkusio/quarkus/pull/14734. It would be great if you could test your app with quarkus master branch or 1.11.2 that should be released shortly.
My point was that it should work even if you skip the
@DisallowConcurrentExecutionannotation.Ok, I’ll repeat it once again:
Scheduled#concurrentExecution()was not intended as a cluster functionality.