diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-06-26 16:24:08 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-07-09 14:51:02 +0200 |
commit | a1a29d14c8cdeb3d5a5e541ec73ff3f42f11ee03 (patch) | |
tree | 26c615951b9809666498334b97c2c7d28179dfce /lib/private/BackgroundJob | |
parent | ecbc1b10aec9cad95b2818077dd38738fe96fee9 (diff) | |
download | nextcloud-server-a1a29d14c8cdeb3d5a5e541ec73ff3f42f11ee03.tar.gz nextcloud-server-a1a29d14c8cdeb3d5a5e541ec73ff3f42f11ee03.zip |
Unlock failed cron jobs and set a high "last_checked" value to avoid continous re-check
* fixes issue where cronjobs of a not-loaded app are marked as "still running" because there is a "reserved_at" value stored
* fixed #9992
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/BackgroundJob')
-rw-r--r-- | lib/private/BackgroundJob/JobList.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index a926194e9df..856354f1590 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -186,6 +186,7 @@ class JobList implements IJobList { $query->select('*') ->from('jobs') ->where($query->expr()->lte('reserved_at', $query->createNamedParameter($this->timeFactory->getTime() - $this->jobTimeOut, IQueryBuilder::PARAM_INT))) + ->andWhere($query->expr()->lte('last_checked', $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT))) ->orderBy('last_checked', 'ASC') ->setMaxResults(1); @@ -214,6 +215,14 @@ class JobList implements IJobList { $job = $this->buildJob($row); if ($job === null) { + // set the last_checked to 12h in the future to not check failing jobs all over again + $reset = $this->connection->getQueryBuilder(); + $reset->update('jobs') + ->set('reserved_at', $reset->expr()->literal(0, IQueryBuilder::PARAM_INT)) + ->set('last_checked', $reset->createNamedParameter($this->timeFactory->getTime() + 12 * 3600, IQueryBuilder::PARAM_INT)) + ->where($reset->expr()->eq('id', $reset->createNamedParameter($row['id'], IQueryBuilder::PARAM_INT))); + $reset->execute(); + // Background job from disabled app, try again. return $this->getNext(); } |