Quarkus-Quartz: Jobs running concurrently in clustered environment

See original GitHub issue

Describe 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:

  1. Setup project with quarkus and quartz
  2. Create the job mentioned above
  3. 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 -a or ver: 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 --version or gradlew --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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mkoubacommented, Feb 9, 2021

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 the is_nonconcurrent column maps to @DisallowConcurrentExecution I 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.

1reaction
mkoubacommented, Feb 9, 2021

When I change to using programmatic scheduling in combination with DisallowConcurrentExecution, my jobs will not be started concurrently in any way.

My point was that it should work even if you skip the @DisallowConcurrentExecution annotation.

Conclusion: To me it looks like preventing concurrent execution does not work as expected.

Ok, I’ll repeat it once again:

  1. Scheduled#concurrentExecution() was not intended as a cluster functionality.
  2. There was a bug that should be fixed in the linked pull request.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Scheduling Periodic Tasks with Quartz - Quarkus
Modern applications often need to run specific tasks periodically. In this guide, you learn how to schedule periodic clustered tasks using the Quartz...
Read more >
Configuring Quartz Scheduler to Run in Clustered Environment
The goal of running a Quartz job in the clustered environment is NOT to have duplicate running jobs. The triggered job should run...
Read more >
Quartz Configuration Reference
"Global" listeners listen to the events of every job/trigger rather than just the jobs/triggers that directly reference them. Configuring listeners through the ...
Read more >
Scheduling Periodic Tasks with Quartz - Quarkus
Updating the application configuration file · Indicate that the scheduler will be run in clustered mode · Use the database store to persist...
Read more >
Running tasks in pods using jobs - OpenShift Documentation
A job executes a task in your OpenShift Container Platform cluster. A job tracks the overall progress of a task and updates its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found