-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Many cron processes can wait locks and consume resources #25987
Comments
Hi @ilnytskyi. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. @ilnytskyi do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
Hi @engcom-Charlie. Thank you for working on this issue.
|
Hello @ilnytskyi We are not able to reproduce this issue on the latest 2.4-develop branch by provided steps. Result:
Could you verify my steps? |
@engcom-Charlie
You can see it on gif. Although on local fresh installation it goes fast this can be a problem on live server with high load. mb smth like this for cron command can be used
or this
However I noticed some command still try to execute simultaneously in second solution, and using it in the loop can froze other jobs. Probably smth like first solution should be used on the shell level |
@ilnytskyi |
✅ Confirmed by @engcom-Charlie Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself. |
Hi @ivan-koliadynskyy. Thank you for working on this issue.
|
The workaround can be like this: |
@ilnytskyi I am also facing the same issue in my prod environment. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions. |
Same here with fix applied to 2.4.1. Only thing that really works is the workaround from the issue creator: "Install each cron group separetely with flock instead adding default cron:run in crontab." |
The deadlocks still occur? Or the cron_schedule table still grows? Or do you refer to this issue occurring of overlapping groups? There’s 3 issues referenced. Worth noting the PR targeted 2.4 in the end and I think might not work on 2.3 completely as there are many other changes in 2.4 to assist in fixing the same issue. |
@HenKun Can you describe your concern/steps in a new issue? |
I’m not sure if there might be confusion between the SQL Deadlock exception the PR targets and what is happening here which I guess is a process deadlock (or process queuing) due to some form of serialisation |
@driskell |
Is this fixed now? And if so, from which version onwards is it safe to remove the flock from cron without flooding the memory? |
@memen45: Magento then added another lock fix for crons in 2.3.5 by MC-25132 and then there were some other smaller improvements done by #28007 which got included in Magento 2.4.3, but I'm not entirely sure how much that last bit helps. Not sure if this is the full story though, but maybe it helps? |
This still happens in 2.4.2 community. Introduced flock and separated the corn group now. Will report back if it still happens. |
@Adel-Magebinary: as mentioned in the post above yours, some extra smaller improvements were made in Magento 2.4.3, maybe you could try to upgrade Magento first? |
related topic: #35639 |
@ilnytskyi would you mind letting me know how to find the "/path/to/lock" in the flock command pls? I did a debug in my local environment and noticed the lock was generated in DB. It would be great if you could elaborate on if the lock is generated differently (like the lock is generated in a file) in the server when in production mode. |
@rukrlf just put that path to any location you want, the lock files are created automatically |
Hey Stanislav,
Thanks for your quick response! and thanks a lot for your answer!
Cheers mate!
…On Mon, Sep 11, 2023 at 12:34 PM Stanislav Ilnytskyi < ***@***.***> wrote:
@rukrlf <https://github.com/rukrlf> just put that path to any location
you want, the lock files are created automatically
https://www.thegeekdiary.com/flock-command-examples-in-linux/
—
Reply to this email directly, view it on GitHub
<#25987 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVV6HMOBPAFMLCVZHPVOP3XZ2ZXJANCNFSM4JZMDICA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
we are still getting the same problem with Magento 2.4.5-p5. Any other solution? |
Preconditions (*)
magento 2.3.x
cron:run
is sent to shellsee this method
\Magento\Cron\Observer\ProcessCronQueueObserver::execute
The problem, I suppose, that magetno uses the same method to run all groups or one group
in \Magento\Cron\Observer\ProcessCronQueueObserver::execute
it creates commands in shell
and only then, it runs the command like this
php bin/magento cron:run --group=index --bootstrap=standaloneProcessStarted=1
it goes to this part
Technically possible to remove all locks and run many
bin/magento cron:run &
and see dozens of created processes in shelle.g. indexer
php bin/magento cron:run --group=index --bootstrap=standaloneProcessStarted=1
Steps to reproduce (*)
bin/magento cron:run &
a few times in backgroundeg
php bin/magento cron:run --group=index --bootstrap=standaloneProcessStarted=1
Expected result (*)
Actual result (*)
GIF:
WORKAROUND:
Install each cron group separetely with flock instead adding default cron:run in crontab.
The text was updated successfully, but these errors were encountered: