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>
This commit is contained in:
parent
ecbc1b10ae
commit
a1a29d14c8
|
@ -186,6 +186,7 @@ class JobList implements IJobList {
|
||||||
$query->select('*')
|
$query->select('*')
|
||||||
->from('jobs')
|
->from('jobs')
|
||||||
->where($query->expr()->lte('reserved_at', $query->createNamedParameter($this->timeFactory->getTime() - $this->jobTimeOut, IQueryBuilder::PARAM_INT)))
|
->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')
|
->orderBy('last_checked', 'ASC')
|
||||||
->setMaxResults(1);
|
->setMaxResults(1);
|
||||||
|
|
||||||
|
@ -214,6 +215,14 @@ class JobList implements IJobList {
|
||||||
$job = $this->buildJob($row);
|
$job = $this->buildJob($row);
|
||||||
|
|
||||||
if ($job === null) {
|
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.
|
// Background job from disabled app, try again.
|
||||||
return $this->getNext();
|
return $this->getNext();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue