Made runJobs.php fully respect $wgJobBackoffThrottling
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 3 Apr 2014 01:20:16 +0000 (18:20 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 3 Apr 2014 01:20:16 +0000 (18:20 -0700)
* Previously, it did not if --type was used
* A --nothrottle option was added to ignore throttling

Change-Id: Ib3ca899f1ce30250a63084096f1b660c96e359fe

includes/DefaultSettings.php
maintenance/runJobs.php

index bb5d26d..fb3078d 100644 (file)
@@ -6207,6 +6207,7 @@ $wgJobTypesExcludedFromDefaultQueue = array( 'AssembleUploadChunks', 'PublishSta
  * on each job runner process. The meaning of "work items" varies per job,
  * but typically would be something like "pages to update". A single job
  * may have a variable number of work items, as is the case with batch jobs.
+ * This is used by runJobs.php and not jobs run via $wgJobRunRate.
  * These settings should be global to all wikis.
  */
 $wgJobBackoffThrottling = array();
index f7d5fc0..0926f41 100644 (file)
@@ -36,6 +36,7 @@ class RunJobs extends Maintenance {
                $this->addOption( 'maxtime', 'Maximum amount of wall-clock time', false, true );
                $this->addOption( 'type', 'Type of job to run', false, true );
                $this->addOption( 'procs', 'Number of processes to use', false, true );
+               $this->addOption( 'nothrottle', 'Ignore job throttling configuration', false, false );
        }
 
        public function memoryLimit() {
@@ -66,6 +67,7 @@ class RunJobs extends Maintenance {
                $type = $this->getOption( 'type', false );
                $maxJobs = $this->getOption( 'maxjobs', false );
                $maxTime = $this->getOption( 'maxtime', false );
+               $noThrottle = $this->hasOption( 'nothrottle' );
                $startTime = time();
 
                $group = JobQueueGroup::singleton();
@@ -83,10 +85,12 @@ class RunJobs extends Maintenance {
                $flags = JobQueueGroup::USE_CACHE;
                $lastTime = time(); // time since last slave check
                do {
+                       $backoffs = array_filter( $backoffs, $backoffExpireFunc );
+                       $blacklist = $noThrottle ? array() : array_keys( $backoffs );
                        if ( $type === false ) {
-                               $backoffs = array_filter( $backoffs, $backoffExpireFunc );
-                               $blacklist = array_keys( $backoffs );
                                $job = $group->pop( JobQueueGroup::TYPE_DEFAULT, $flags, $blacklist );
+                       } elseif ( in_array( $type, $blacklist ) ) {
+                               $job = false; // requested queue in backoff state
                        } else {
                                $job = $group->pop( $type ); // job from a single queue
                        }