Skip to content

Commit

Permalink
Merge pull request #41359 from nextcloud/backport/41295/stable27
Browse files Browse the repository at this point in the history
[stable27] fix(JobList#hasReservedJob): Break tie when multiple jobs are reserved
  • Loading branch information
marcelklehr authored Nov 10, 2023
2 parents 4ffee4f + 708c0a8 commit 8e29b02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/private/BackgroundJob/JobList.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public function hasReservedJob(?string $className = null): bool {
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('jobs')
->where($query->expr()->neq('reserved_at', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
->where($query->expr()->gt('reserved_at', $query->createNamedParameter($this->timeFactory->getTime() - 6 * 3600, IQueryBuilder::PARAM_INT)))
->setMaxResults(1);

if ($className !== null) {
Expand Down
3 changes: 2 additions & 1 deletion lib/public/BackgroundJob/IJobList.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ public function setExecutionTime(IJob $job, int $timeTaken): void;
public function resetBackgroundJob(IJob $job): void;

/**
* Checks whether a job of the passed class is reserved to run
* Checks whether a job of the passed class was reserved to run
* in the last 6h
*
* @param string|null $className
* @return bool
Expand Down

0 comments on commit 8e29b02

Please sign in to comment.