@@ -48,9 +48,6 @@ class JobList implements IJobList {
4848 /**@var ITimeFactory */
4949 protected $ timeFactory ;
5050
51- /** @var int - 12 hours * 3600 seconds*/
52- private $ jobTimeOut = 43200 ;
53-
5451 /**
5552 * @param IDBConnection $connection
5653 * @param IConfig $config
@@ -186,7 +183,7 @@ public function getNext() {
186183 $ query = $ this ->connection ->getQueryBuilder ();
187184 $ query ->select ('* ' )
188185 ->from ('jobs ' )
189- ->where ($ query ->expr ()->lte ('reserved_at ' , $ query ->createNamedParameter ($ this ->timeFactory ->getTime () - $ this -> jobTimeOut , IQueryBuilder::PARAM_INT )))
186+ ->where ($ query ->expr ()->lte ('reserved_at ' , $ query ->createNamedParameter ($ this ->timeFactory ->getTime () - 12 * 3600 , IQueryBuilder::PARAM_INT )))
190187 ->andWhere ($ query ->expr ()->lte ('last_checked ' , $ query ->createNamedParameter ($ this ->timeFactory ->getTime (), IQueryBuilder::PARAM_INT )))
191188 ->orderBy ('last_checked ' , 'ASC ' )
192189 ->setMaxResults (1 );
@@ -346,39 +343,4 @@ public function setExecutionTime(IJob $job, $timeTaken) {
346343 ->where ($ query ->expr ()->eq ('id ' , $ query ->createNamedParameter ($ job ->getId (), IQueryBuilder::PARAM_INT )));
347344 $ query ->execute ();
348345 }
349-
350- /**
351- * checks if a job is still running (reserved_at time is smaller than 12 hours ago)
352- *
353- * Background information:
354- *
355- * The 12 hours is the same timeout that is also used to re-schedule an non-terminated
356- * job (see getNext()). The idea here is to give a job enough time to run very
357- * long but still be able to recognize that it maybe crashed and re-schedule it
358- * after the timeout. It's more likely to be crashed at that time than it ran
359- * that long.
360- *
361- * In theory it could lead to an nearly endless loop (as in - at most 12 hours).
362- * The cron command will not start new jobs when maintenance mode is active and
363- * this method is only executed in maintenance mode (see where it is called in
364- * the upgrader class. So this means in the worst case we wait 12 hours when a
365- * job has crashed. On the other hand: then the instance should be fixed anyways.
366- *
367- * @return bool
368- */
369- public function isAnyJobRunning (): bool {
370- $ query = $ this ->connection ->getQueryBuilder ();
371- $ query ->select ('* ' )
372- ->from ('jobs ' )
373- ->where ($ query ->expr ()->gt ('reserved_at ' , $ query ->createNamedParameter ($ this ->timeFactory ->getTime () - $ this ->jobTimeOut , IQueryBuilder::PARAM_INT )))
374- ->setMaxResults (1 );
375- $ result = $ query ->execute ();
376- $ row = $ result ->fetch ();
377- $ result ->closeCursor ();
378-
379- if ($ row ) {
380- return true ;
381- }
382- return false ;
383- }
384346}
0 commit comments