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
Disable cron:run when maintenance mode is enabled #21181
Conversation
Hi @kassner. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
This is true only for some cases, I'm not sure if this should be included in the core. Maybe create a config instead of assuming this applies to everybody? |
Hi @miguelbalparda, |
It depends on how people is using maintenance mode. I've seen admins putting the site in that mode just to do changes on prices or CMS pages or even deploying new code changes while on maintenance, which sometimes require crons to be run. |
So in this case would be better to add some parameter to env.php file, for
instance “disable_cron_running_in_maintenance_mode”. If this parameter
exists and it is set to 1 - than cron jobs should not be running.
What do you think?
…On Wed, Feb 13, 2019 at 13:24 Miguel Balparda ***@***.***> wrote:
It depends on how people is using maintenance mode. I've seen admins
putting the site in that mode just to do changes on prices or CMS pages or
even deploying new code changes while on maintenance, which sometimes
require crons to be run.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#21181 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AByXUTH7JT77JCGWS4yeJrx-sTsel0sqks5vM_X-gaJpZM4a4-da>
.
|
I think that’s no different than disabling Magento_Cron using the bin/magento tool and should have the same effect without adding anything to the core for an use case that’s not super intuitive. |
Disabling Magento_Cron with |
Which is consistent with the description of this PR regarding no DB writes while in maintenance, achieving virtually the same objective. |
With disabling cron module we’ll have few issues:
1. We’ll have errors that command cron:run doesn’t exists, these messages
will be sent to email. As for me - it’s not expected
2. Any amount of modules might have dependence on cron module, so we have
to disable all together, it means - not really useful
…On Wed, Feb 13, 2019 at 16:15 Miguel Balparda ***@***.***> wrote:
Which is consistent with the description of this PR regarding no DB writes
while in maintenance, achieving virtually the same objective.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#21181 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AByXUe02G8XiaUuiFkTsXc2KzW0V72lBks5vNB3wgaJpZM4a4-da>
.
|
@miguelbalparda no, as I am enabling maintenance mode just because I want to run |
Maintenance windows are very short usually, which means --force can be used to disable Magento_Cron just for the duration of the window without causing much issues. I still don't see why an edge case like this should be considered in the core, the reasoning behind an inclusion should be a broader benefit and I don't see that in this issue. In either case, this should be consulted with an architect IMO. |
I think it is a good idea to disable cron by default during maintenance mode as it appears to be the safes approach. I'd add a command option to |
Hi @kandy @buskamuza, |
if ($this->maintenanceMode->isOn()) { | ||
$output->writeln('<info>' . 'Cron is disabled because the maintenance mode is enabled.' . '</info>'); | ||
return; | ||
} | ||
if (!$this->deploymentConfig->get('cron/enabled', 1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pay attention to this configuration. You already may disable cron. Add cron/enabled as 0 to configuration file. There is no special CLI command for this setting for now.
Hi, |
@NadiyaS good catch! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
As we discussed with Architects in #appdesign
- it's better to introduce cron:enable
and cron:disable
CLI commands, that will fit all needs and will not add backward incompatible changes.
@kassner could you update your PR with these chagnes?
@kassner , I am closing this PR now due to inactivity. |
Hi @kassner, thank you for your contribution! |
Description
I believe cron jobs should be disabled while
setup:upgrade
is being run, to avoid concurrent accesses, which can lead to table locks that can make setup upgrade fail, plus we'll be using stale/wrong data for the cron jobs.Since the maintenance mode makes sure the frontend is inaccessible, avoiding any writes to the database through it, I believe we should disable crons as well, as they have a heavy impact on the database.
Manual testing scenarios
php bin/magento maintenance:enable
;php bin/magento cron:run
;Contribution checklist