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.
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 thedefault
cron group - all other groups run jobs in sequencemaxjobs
setting is applicable (or not applicable)Other more involved ideas
Story
Acceptance Criteria