Skip to content

Crons parallelization management #35639

@Nuranto

Description

@Nuranto

Summary (*)

Magento 2.4.4

Crons groups that can be parallelized are launched via the main cron:run command. This can be a problem if that process is taking too long.

Examples (*)

Use case :

Let's say you have one group group_example that have use_separate_process to 1, where there is a job job_example that need to be executed every minutes.
Let's also say that the others groups are taking 10min to execute (long reindex, or whatever).

It means that the command /usr/local/bin/php /var/www/html/bin/magento cron:run --group=group_example --bootstrap=standaloneProcessStarted=1 is run every 10 minutes.

Which means job_example may not be executing for 10 minutes.

(the number "10" minutes is arbitrary for the example, I'm sure sometimes it could be a lot more)

Proposed solution

It would be more safe and logical if the separate processes were not launched by the cron:run command.
Those parallelization-friendly groups should be added to crontab by cron:install directly.

Also, other subject but a linked one, we should probably prevent cron:run to be launched when another is already running to avoid accumulation risks. cron:run can be launched with flock for instance : flock -w 0 /tmp/magento.cron.lock /usr/local/bin/php {magentoRoot}bin/magento cron:run

Of course, we can modify all this manually via di.xml, but maybe it should be native.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users with no workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrameworkComponent: CronIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: ready for devReported on 2.4.4Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions