Skip to content

Commit 8e29b02

Browse files
authored
Merge pull request #41359 from nextcloud/backport/41295/stable27
[stable27] fix(JobList#hasReservedJob): Break tie when multiple jobs are reserved
2 parents 4ffee4f + 708c0a8 commit 8e29b02

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

lib/private/BackgroundJob/JobList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public function hasReservedJob(?string $className = null): bool {
406406
$query = $this->connection->getQueryBuilder();
407407
$query->select('*')
408408
->from('jobs')
409-
->where($query->expr()->neq('reserved_at', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
409+
->where($query->expr()->gt('reserved_at', $query->createNamedParameter($this->timeFactory->getTime() - 6 * 3600, IQueryBuilder::PARAM_INT)))
410410
->setMaxResults(1);
411411

412412
if ($className !== null) {

lib/public/BackgroundJob/IJobList.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ public function setExecutionTime(IJob $job, int $timeTaken): void;
147147
public function resetBackgroundJob(IJob $job): void;
148148

149149
/**
150-
* Checks whether a job of the passed class is reserved to run
150+
* Checks whether a job of the passed class was reserved to run
151+
* in the last 6h
151152
*
152153
* @param string|null $className
153154
* @return bool

0 commit comments

Comments
 (0)