summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2016-04-22 10:49:55 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2016-04-22 14:11:26 +0200
commit3e1dc647376c998f5e7752e8e7b39582144e1398 (patch)
tree8608b60bed8a3e747dd5b39344324885196a949e /lib
parent27d6852b3ead63454d3cf0f3c79372af6852f9ac (diff)
downloadnextcloud-server-3e1dc647376c998f5e7752e8e7b39582144e1398.tar.gz
nextcloud-server-3e1dc647376c998f5e7752e8e7b39582144e1398.zip
Change the sort order of background jobs to be DESC instead of ASC
In theory, if your instance ever creates more jobs then your system cron can handle, the default background jobs get never executed anymore. Because everytime when the joblist returns the next job it looks for the next ID, however there is always a new next ID, so it will never wrap back to execute the low IDs. But when we change the sort order to be DESC, we make sure that these low IDs are always executed, before the system jumps back up to execute the new IDs.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/backgroundjob/joblist.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php
index b8230fca4de..2429b830446 100644
--- a/lib/private/backgroundjob/joblist.php
+++ b/lib/private/backgroundjob/joblist.php
@@ -172,8 +172,8 @@ class JobList implements IJobList {
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('jobs')
- ->where($query->expr()->gt('id', $query->createNamedParameter($lastId, IQueryBuilder::PARAM_INT)))
- ->orderBy('id', 'ASC')
+ ->where($query->expr()->lt('id', $query->createNamedParameter($lastId, IQueryBuilder::PARAM_INT)))
+ ->orderBy('id', 'DESC')
->setMaxResults(1);
$result = $query->execute();
$row = $result->fetch();
@@ -187,7 +187,7 @@ class JobList implements IJobList {
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('jobs')
- ->orderBy('id', 'ASC')
+ ->orderBy('id', 'DESC')
->setMaxResults(1);
$result = $query->execute();
$row = $result->fetch();