-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Wait for cron to finish before running upgrade command #9900
Conversation
I'm tempted to backport this, because we think that this could fix the issue #4978 |
Codecov Report
@@ Coverage Diff @@
## master #9900 +/- ##
===========================================
- Coverage 52.07% 51.9% -0.17%
+ Complexity 25901 25813 -88
===========================================
Files 1642 1637 -5
Lines 95884 95539 -345
Branches 1318 1318
===========================================
- Hits 49929 49593 -336
+ Misses 45955 45946 -9
|
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.
Makes a lot of sense!
$query = $this->connection->getQueryBuilder(); | ||
$query->select('*') | ||
->from('jobs') | ||
->where($query->expr()->gt('reserved_at', $query->createNamedParameter($this->timeFactory->getTime() - 12 * 3600, IQueryBuilder::PARAM_INT))) |
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.
Let's document why this is supposed to be working. The code is clear, but the thought behinds should be expressed.
Strictly speaking, it does only report whether a job should run (it might be running, or it might be due with the next job run). Correct me if I am wrong. It could perhaps lead to an infinite loop when a job reincarnates and registers to run next time again. Though, cron should not be triggered when maintenance mode is enabled, which in the whole scenario is the case, so it would block for 12 hours instead.
Are the 12 hours based on something?
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.
The 12 hours is the same timeout that is also used to re-schedule an non-terminated job (see a bit above in this file - getNextJob()
. The idea here is: give a job enough time to run very long and then after a timeout re-schedule it nevertheless. It's more likely to be crashed than to run that long.
In theory it could lead to an endless loop (as in - at most 12 hours), because the cron will not start when maintenance mode is active and this method is only executed in maintenance mode (see where it is added in the upgrader class. I could add this as comments of course.
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.
Comment added.
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.
From a UX perspective it still is problematic if it will take that long, as it'll look that nothing is happening. Of course stating "it might take up to 12 hours" in the GUI would scare people away. OK, let's get it in and collect some experience.
* fixes #9562 Signed-off-by: Morris Jobke <hey@morrisjobke.de>
b0c929d
to
18e9631
Compare
Let's not backport this. |
Reverted in #12188 |
To test this, add this:
Then start a cron job
cron.php
, raise the version number inversion.php
or lower it inconfig/config.php
and then trigger the upgrade by callingocc upgrade
.It then looks like this:
When no cron job runs, then it looks like this: