From: Aaron Schulz Date: Thu, 31 Jan 2013 04:14:56 +0000 (-0800) Subject: [JobQueue] Re-try jobs that fail normally. X-Git-Tag: 1.31.0-rc.0~20853 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=77ae02cebf73945f4171b1fd6a24432890d5a8a1;p=lhc%2Fweb%2Fwiklou.git [JobQueue] Re-try jobs that fail normally. * Jobs will be re-attempted if run() returns false. This means that claimTTL is useful beyond just the case where runners get killed in the middle of a job or an uncaught exception is thrown. * Moved MAX_ATTEMPTS constant up to base class. * Clarified docs a bit. Change-Id: Id7f970e82a63aa563e9a7a023ce32e5d6680433a --- diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php index 17f6648fc2..6cdc948231 100644 --- a/includes/job/JobQueue.php +++ b/includes/job/JobQueue.php @@ -36,6 +36,8 @@ abstract class JobQueue { const QoS_Atomic = 1; // integer; "all-or-nothing" job insertions + const MAX_ATTEMPTS = 3; // integer; number of times to try a job + /** * @param $params array */ @@ -61,7 +63,9 @@ abstract class JobQueue { * If "random" is used, pop() will pick jobs in random order. This might be * useful for improving concurrency depending on the queue storage medium. * - claimTTL : If supported, the queue will recycle jobs that have been popped - * but not acknowledged as completed after this many seconds. + * but not acknowledged as completed after this many seconds. Recycling + * of jobs simple means re-inserting them into the queue. Jobs can be + * attempted up to three times before being discarded. * * Queue classes should throw an exception if they do not support the options given. * diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index 1c9c8a74c5..99a517e68f 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -31,7 +31,6 @@ class JobQueueDB extends JobQueue { const CACHE_TTL_SHORT = 30; // integer; seconds to cache info without re-validating const CACHE_TTL_LONG = 300; // integer; seconds to cache info that is kept up to date const MAX_AGE_PRUNE = 604800; // integer; seconds a job can live once claimed - const MAX_ATTEMPTS = 3; // integer; number of times to try a job const MAX_JOB_RANDOM = 2147483647; // integer; 2^31 - 1, used for job_random const MAX_OFFSET = 255; // integer; maximum number of rows to skip diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index 85b0993df0..0cf02174b7 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -85,7 +85,9 @@ class RunJobs extends Maintenance { $t = microtime( true ); $this->runJobsLog( $job->toString() . " STARTING" ); $status = $job->run(); - $group->ack( $job ); // done + if ( $status ) { + $group->ack( $job ); // done + } $t = microtime( true ) - $t; $timeMs = intval( $t * 1000 ); if ( !$status ) {