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

Crons parallelization management #35639

Open
1 of 5 tasks
Nuranto opened this issue Jun 18, 2022 · 11 comments
Open
1 of 5 tasks

Crons parallelization management #35639

Nuranto opened this issue Jun 18, 2022 · 11 comments
Labels
Area: Framework Component: Cron Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: ready for dev Reported on 2.4.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@Nuranto
Copy link
Contributor

Nuranto commented Jun 18, 2022

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”.
@Nuranto Nuranto added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Jun 18, 2022
@m2-assistant
Copy link

m2-assistant bot commented Jun 18, 2022

Hi @Nuranto. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@ghost
Copy link

ghost commented Jun 26, 2022

Same issue on 2.4.3-p2 version

@engcom-Lima
Copy link
Contributor

Hi @Nuranto,
Thanks for the collaboration and reporting the issue.
Can you please provide us with the exact steps to reproduce this issue.

Thanks!

@engcom-Lima engcom-Lima self-assigned this Jul 21, 2022
@m2-assistant

This comment was marked as off-topic.

@engcom-Lima engcom-Lima added the Issue: needs update Additional information is require, waiting for response label Jul 21, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Jul 21, 2022
@Nuranto
Copy link
Contributor Author

Nuranto commented Jul 23, 2022

Hi @engcom-Lima,

  1. Create a custom cron (default group) that just sleep for 30 minutes. Configure it for execution every minutes
  2. Run crons

Expected behaviour

After a 30 minutes, Only one cron process is started/running

Actual behaviour

After 30 minutes, we have 30 cron processes running, possibly consuming all resources if sleep is being replaced by actual code.

@engcom-Lima
Copy link
Contributor

Hi @Nuranto

Thanks for the input,
I tried to reproduce this issue with latest 2.4-develop instance however the issue is still not reproducible

Steps followed to reproduce the issue

  1. Install latest 2.4-develop instance
  2. Create custom cron that will just sleep for sometime(tried with 5 mins) group=default
  3. Configure group to run every minute and set use_separate_process to 1

Only one process was started and cannot see more that one process running

Do let me know if I have missed any steps will reverify again

Thanks

@Nuranto
Copy link
Contributor Author

Nuranto commented Aug 5, 2022

Hello @engcom-Lima

You need to set use_separate_process to 0 to reproduce the issue.

@engcom-Lima
Copy link
Contributor

Hi @Nuranto,
Thank you for the reply

Reverified with again and the issue is reproducible,

IMAGE UPLOAD
Screenshot 2022-08-08 at 11 37 42 AM

Hence confirming the issue

Thanks

@engcom-Lima engcom-Lima added Reported on 2.4.4 Indicates original Magento version for the Issue report. Component: Cron Area: Framework Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 8, 2022
@m2-community-project m2-community-project bot moved this from Needs Update to Confirmed in Issue Confirmation and Triage Board Aug 8, 2022
@m2-community-project m2-community-project bot removed the Issue: needs update Additional information is require, waiting for response label Aug 8, 2022
@engcom-Lima engcom-Lima removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 8, 2022
@m2-community-project m2-community-project bot moved this from Confirmed to Ready for Confirmation in Issue Confirmation and Triage Board Aug 8, 2022
@engcom-Lima engcom-Lima added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: ready for confirmation labels Aug 8, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Aug 8, 2022
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-6314 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Aug 8, 2022

✅ Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-6314

@engcom-Hotel engcom-Hotel added the Priority: P3 May be fixed according to the position in the backlog. label Aug 9, 2022
@m2-community-project m2-community-project bot added this to Ready for Development in Low Priority Backlog Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Cron Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: ready for dev Reported on 2.4.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Low Priority Backlog
  
Ready for Development
Development

No branches or pull requests

4 participants