Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for exclusive job execution within cron groups #122

Open
JesKingDev opened this issue Feb 24, 2022 · 0 comments
Open

Add support for exclusive job execution within cron groups #122

JesKingDev opened this issue Feb 24, 2022 · 0 comments

Comments

@JesKingDev
Copy link
Contributor

Background

The standard cron multi-threading support in Magento comes from defining cron groups whose jobs run in a separate thread. This provides more throughput, which becomes unnecessary and therefore ignored in this module.

However, there are instances where crons should not execute simultaneously. The standard practice in Magento is to create cron groups that define these jobs, given there is some assurance that they will not execute at the same time.

With this module, however, parallel execution is governed by the setting for max # of jobs and not based on cron groups.

Design

Some perhaps straightforward ideas

  • maxjobs only applies to the default cron group - all other groups run jobs in sequence
  • add a new configuration option to choose groups for which maxjobs setting is applicable (or not applicable)

Other more involved ideas

  • Propose additional configuration(s) in urn:magento:module:Magento_Cron:etc/cron_groups.xsd to specify if the cron group jobs can run in parallel
  • Implement a resource lock configuration in urn:magento:module:Magento_Cron:etc/crontab.xsd which could be similar to ACL resource declarations. This resource lock could then be checked prior to the cron execution to ensure that the resource is available. For example, if a cron job is creating credit memos for orders, the cron job could request a lock on Orders and Credit Memos. If a job processing RMAs needs to execute and requires the same resources, it would need to wait to be executed until the locks are released.
  • add support for exclusive execution for specific jobs - examples for this would be a backup job, a sync job, etc. that only makes sense when other jobs are not touching the filesystem or db

Story

  • As a Magento developer
  • I want to set a configuration
  • so that I can ensure a specific cron job does not execute concurrently with others that may conflict.

Acceptance Criteria

  • Scenario – Job should execute exclusively
  • Given Two jobs are scheduled to run at the current time
  • When a configuration is set for that job or the job's group which specifies the two jobs should not run concurrently (or similarly, that the job or group should execute in sequence)
  • Then only one of the two jobs will be executed immediately
  • and the other will only run after the first has finished executing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant